Skip to content

Commit f2685fc

Browse files
committed
internal/mcp: add a script to create the mcp SDK repo
Add a script that will be used to fully set up the modelcontextprotocol/go-sdk repo. Change-Id: Icadcb3a6368bf8ee3691c63e2b60ac01f42186e4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/682795 Auto-Submit: Robert Findley <[email protected]> Reviewed-by: Alan Donovan <[email protected]> TryBot-Bypass: Robert Findley <[email protected]> Commit-Queue: Robert Findley <[email protected]>
1 parent 231c38c commit f2685fc

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

internal/mcp/create-repo.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
# This script creates an MCP SDK repo from x/tools/internal/mcp (and friends).
4+
# It will be used as a one-off to create github.com/modelcontextprotocol/go-sdk.
5+
#
6+
# Requires https://github.com/newren/git-filter-repo.
7+
8+
set -eu
9+
10+
# Check if exactly one argument is provided
11+
if [ "$#" -ne 1 ]; then
12+
echo "create-repo.sh: create a standalone mcp SDK repo from x/tools"
13+
echo "Usage: $0 <mcp repo destination>"
14+
exit 1
15+
fi >&2
16+
17+
src=$(go list -m -f {{.Dir}} golang.org/x/tools)
18+
dest="$1"
19+
20+
echo "Filtering MCP commits from ${src} to ${dest}..." >&2
21+
22+
startdir=$(pwd)
23+
tempdir=$(mktemp -d)
24+
function cleanup {
25+
echo "cleaning up ${tempdir}"
26+
rm -rf "$tempdir"
27+
} >&2
28+
trap cleanup EXIT SIGINT
29+
30+
echo "Checking out to ${tempdir}"
31+
32+
git clone --bare "${src}" "${tempdir}"
33+
git -C "${tempdir}" --git-dir=. filter-repo \
34+
--path internal/mcp/jsonschema --path-rename internal/mcp/jsonschema:jsonschema \
35+
--path internal/mcp/design --path-rename internal/mcp/design:design \
36+
--path internal/mcp/examples --path-rename internal/mcp/examples:examples \
37+
--path internal/mcp/internal --path-rename internal/mcp/internal:internal \
38+
--path internal/mcp/README.md --path-rename internal/mcp/README.md:README.md \
39+
--path internal/mcp/CONTRIBUTING.md --path-rename internal/mcp/CONTRIBUTING.md:CONTRIBUTING.md \
40+
--path internal/mcp --path-rename internal/mcp:mcp \
41+
--path internal/jsonrpc2_v2 --path-rename internal/jsonrpc2_v2:internal/jsonrpc2 \
42+
--path internal/xcontext \
43+
--replace-text "${startdir}/mcp-repo-replace.txt" \
44+
--force
45+
mkdir ${dest}
46+
cd "${dest}"
47+
git init
48+
49+
cat << EOF > LICENSE
50+
MIT License
51+
52+
Copyright (c) 2025 Go MCP SDK Authors
53+
54+
Permission is hereby granted, free of charge, to any person obtaining a copy
55+
of this software and associated documentation files (the "Software"), to deal
56+
in the Software without restriction, including without limitation the rights
57+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
58+
copies of the Software, and to permit persons to whom the Software is
59+
furnished to do so, subject to the following conditions:
60+
61+
The above copyright notice and this permission notice shall be included in all
62+
copies or substantial portions of the Software.
63+
64+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
65+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
66+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
67+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
68+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
69+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
70+
SOFTWARE.
71+
EOF
72+
73+
git add LICENSE && git commit -m "Initial commit: add LICENSE"
74+
git remote add filtered_source "${tempdir}"
75+
git pull filtered_source master --allow-unrelated-histories
76+
git remote remove filtered_source
77+
go mod init github.com/modelcontextprotocol/go-sdk && go get [email protected]
78+
go mod tidy
79+
git add go.mod go.sum
80+
git commit -m "all: add go.mod and go.sum file"

internal/mcp/mcp-repo-replace.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
jsonrpc2 "golang.org/x/tools/internal/jsonrpc2_v2"==>"github.com/modelcontextprotocol/go-sdk/internal/jsonrpc2"
2+
golang.org/x/tools/internal/xcontext==>github.com/modelcontextprotocol/go-sdk/internal/xcontext
3+
golang.org/x/tools/internal/mcp/internal==>github.com/modelcontextprotocol/go-sdk/internal
4+
golang.org/x/tools/internal/mcp/jsonschema==>github.com/modelcontextprotocol/go-sdk/jsonschema
5+
golang.org/x/tools/internal/mcp/examples==>github.com/modelcontextprotocol/go-sdk/examples
6+
golang.org/x/tools/internal/mcp/design==>github.com/modelcontextprotocol/go-sdk/design
7+
golang.org/x/tools/internal/mcp==>github.com/modelcontextprotocol/go-sdk/mcp
8+
governed by a BSD-style==>governed by an MIT-style
9+
regex:Copyright (20\d\d) The Go Authors==>Copyright \1 The Go MCP SDK Authors

0 commit comments

Comments
 (0)