mcp: finalize cleanup of Go 1.23, make Go version support explicit
This commit is contained in:
parent
d0922abcd3
commit
6a19c95fea
6 changed files with 24 additions and 55 deletions
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
|
|
@ -40,7 +40,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
go: ["1.23", "1.24", "1.25"]
|
||||
go: ["1.24", "1.25"]
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
|
||||
|
|
|
|||
|
|
@ -38,6 +38,9 @@ The following table shows which versions of the Go SDK support which versions of
|
|||
| v1.2.0+ | 2025-06-18 | 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 |
|
||||
| v1.0.0 - v1.1.0 | 2025-06-18 | 2025-06-18, 2025-03-26, 2024-11-05 |
|
||||
|
||||
New releases of the SDK target only supported versions of Go. See
|
||||
https://go.dev/doc/devel/release#policy for more information.
|
||||
|
||||
## Getting started
|
||||
|
||||
To get started creating an MCP server, create an `mcp.Server` instance, add
|
||||
|
|
|
|||
|
|
@ -37,6 +37,9 @@ The following table shows which versions of the Go SDK support which versions of
|
|||
| v1.2.0+ | 2025-06-18 | 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 |
|
||||
| v1.0.0 - v1.1.0 | 2025-06-18 | 2025-06-18, 2025-03-26, 2024-11-05 |
|
||||
|
||||
New releases of the SDK target only supported versions of Go. See
|
||||
https://go.dev/doc/devel/release#policy for more information.
|
||||
|
||||
## Getting started
|
||||
|
||||
To get started creating an MCP server, create an `mcp.Server` instance, add
|
||||
|
|
|
|||
|
|
@ -113,6 +113,23 @@ func computeURIFilepath(rawURI, dirFilepath string, rootFilepaths []string) (str
|
|||
return uriFilepathRel, nil
|
||||
}
|
||||
|
||||
// withFile calls f on the file at join(dir, rel),
|
||||
// protecting against path traversal attacks.
|
||||
func withFile(dir, rel string, f func(*os.File) error) (err error) {
|
||||
r, err := os.OpenRoot(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Close()
|
||||
file, err := r.Open(rel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Record error, in case f writes.
|
||||
defer func() { err = errors.Join(err, file.Close()) }()
|
||||
return f(file)
|
||||
}
|
||||
|
||||
// fileRoots transforms the Roots obtained from the client into absolute paths on
|
||||
// the local filesystem.
|
||||
// TODO(jba): expose this functionality to user ResourceHandlers,
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright 2025 The Go MCP SDK Authors. All rights reserved.
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.24
|
||||
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
// withFile calls f on the file at join(dir, rel),
|
||||
// protecting against path traversal attacks.
|
||||
func withFile(dir, rel string, f func(*os.File) error) (err error) {
|
||||
r, err := os.OpenRoot(dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer r.Close()
|
||||
file, err := r.Open(rel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Record error, in case f writes.
|
||||
defer func() { err = errors.Join(err, file.Close()) }()
|
||||
return f(file)
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
// Copyright 2025 The Go MCP SDK Authors. All rights reserved.
|
||||
// Use of this source code is governed by an MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !go1.24
|
||||
|
||||
package mcp
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// withFile calls f on the file at join(dir, rel).
|
||||
// It does not protect against path traversal attacks.
|
||||
func withFile(dir, rel string, f func(*os.File) error) (err error) {
|
||||
file, err := os.Open(filepath.Join(dir, rel))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Record error, in case f writes.
|
||||
defer func() { err = errors.Join(err, file.Close()) }()
|
||||
return f(file)
|
||||
}
|
||||
Loading…
Reference in a new issue