Commit graph

237 commits

Author SHA1 Message Date
Jonathan Amsterdam
9b6327b3b7
mcp: add Session.ID (#67) v0.1.0
Support retrieving the session ID from client and server sessions.

Fixes #65.
2025-07-01 13:49:23 -04:00
Sam Thanawalla
e1b1cd0072
mcp: implement completion (#55)
This CL implements a completion handler for the server and a complete
method for the client.

Fixes: #12 
<!-- Provide a brief summary of your changes -->

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
This adds support for completion.

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
Added tests and an example.

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
N/A

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->
2025-07-01 13:09:15 -04:00
Xin
92b6983c1c
mcp: add ResourceLink type (#76)
This PR introduces the ResourceLink type to represent links to
resources. The new type includes the following fields: `uri`, `name`,
`title`, `description`, `mimeType`, `size`, and `_meta`.

This implementation conforms to the `ResourceLink` schema introduced in
the [MCP schema
2025-06-18](1cfdf1e7a8/schema/2025-06-18/schema.json (L1826)).

Note: `ResourceLink` extends from the `Resource` type in the MCP schema.
As such, it inherits support for optional fields like `title`, `_meta`,
etc. Thus, `URI`, `Name`, `Title`, `Description`, and `Size` are added
to the `wireContent`

For reference, the [TypeScript SDK test
suite](fb4d07f0ee/src/types.test.ts (L43))
provides examples demonstrating valid ResourceLink objects with all
optional fields populated.

https://modelcontextprotocol.io/specification/2025-06-18/server/tools#resource-links
- [ResourceLink JSON
Schema](1cfdf1e7a8/schema/2025-06-18/schema.json (L1826))

Signed-off-by: Xin Fu <xfu83@bloomberg.net>

Fixes #14.
2025-07-01 12:41:22 -04:00
Jonathan Amsterdam
95e96a6daa
jsonschema: improve Resolved.Validate doc (#81) 2025-07-01 10:37:03 -04:00
Albert Sundjaja
bfb9215d16
jsonchema: support additional keywords
Support additional (extra) keywords beyond those specified in the
`Schema` type. The current behavior is additional keywords are dropped.

To follow up:

- There are similar util functions in `mcp/util.go` which don't seem to
be used. Maybe we should move it to `internal/util` instead of
`jsonchema/util.go` package?
- The method `[Un]MarshalJSON` is only on `pointer receiver`, is this
intended? (that means it will only work if we [un]marshal pointer to the
`Schema` instance)
- The fix is using the [un]marshalStructWithMap from `mcp/util.go` and
there are requirements for the function to work properly but these are
not strictly checked e.g. need `json:"-"` tag for the Extra field.

Fixes #69.
2025-07-01 07:02:26 -04:00
Jonathan Amsterdam
2facfc6ffe
jsonschema: unexport ForType (#71)
There's no evidence that it's needed.

Also, improve doc and error messages.
2025-06-30 14:44:40 -04:00
Jonathan Amsterdam
c657cc3836
.github: add PR template (#75)
The default template is too elaborate. Add a simpler one.
2025-06-30 14:30:30 -04:00
Jonathan Amsterdam
beed2f0677
mcp: small changes to CallTool structs (#60)
- Use `any` for CallToolResult.StructuredContent.

- Change the non-generic structs into aliases for the generic ones.
2025-06-30 13:47:24 -04:00
Sam Thanawalla
bc59932176
design: add design for rate limiting (#36)
I added an example for how rate limiting should be implemented using
middleware.

Fixes #22 

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->
Rate limiting can be enabled using middleware. This adds an example on
how to do that.

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
N/A

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
No

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [x] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [x] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->
2025-06-30 09:49:55 -04:00
SADIK KUZU
032c62c8ad
Fix typos (#66)
This pull request addresses multiple minor documentation and code
comment fixes to correct typos and improve clarity. These changes do not
introduce functional modifications but enhance readability and
professionalism.

### Documentation Fixes:

* Corrected a typo in the "Security Considerations" section header in
`design/design.md`. ("Securty" → "Security")
* Fixed spelling errors in the "Governance and Community" section of
`design/design.md`. ("accomodating" → "accommodating")
* Updated the "Proposals" section in `design/design.md` to fix a typo.
("accomodate" → "accommodate")

### Code Comment Fixes:

* Corrected a typo in a comment in `mcp/logging.go`. ("LoggingMesssage"
→ "LoggingMessage")
* Fixed a typo in a comment in `mcp/streamable.go`. ("priviledged" →
"privileged")

<!-- Provide a brief summary of your changes -->

## Motivation and Context
<!-- Why is this change needed? What problem does it solve? -->

This PR is for fixing some typos in the repo

## How Has This Been Tested?
<!-- Have you tested this in a real application? Which scenarios were
tested? -->
by code diff

## Breaking Changes
<!-- Will users need to update their code or configurations? -->
N/A

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes
that apply. -->
- [ ] I have read the [MCP
Documentation](https://modelcontextprotocol.io)
- [ ] My code follows the repository's style guidelines
- [ ] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions
-->
2025-06-30 08:11:04 -04:00
cryo
45f700ea13
mcp/client: fix typo in changeAndNotify&ReadResource (#68)
This PR updates the comments for func changeAndNotify and ReadResource to correct typos and improve clarity.
2025-06-30 07:51:01 -04:00
Robert Findley
8a3f272dbb
internal/readme: fix server example (#63)
Fix an example using params.Name instead of params.Arguments.Name. All
credit due to @A11Might for noticing this. Sending a separate PR to keep
the internal/readme source consistent.
2025-06-27 15:43:14 -04:00
Robert Jackson
c47dbcd7b2
mcp: Implement KeepAlive for client and server
Implement KeepAlive features from the design doc.

Fixes #24.
2025-06-27 08:24:05 -04:00
Robert Jackson
9f6dd5c32e
feat(ci): Ensure that the README.md is in sync with internal/readme (#53) 2025-06-26 12:45:44 -04:00
Robert Findley
0e2abbb107
docs: add GitHub discussions to README.md and CONTRIBUTING.md (#49)
Also, update a pkgsite link in the README.
2025-06-26 09:37:21 -04:00
Jonathan Amsterdam
ff0d746521
mcp: fix some documentation (#41)
- Add some doc strings.

- Remove markdown-like notations.
2025-06-25 17:38:37 -04:00
Jonathan Amsterdam
81eb55e6bc
mcp: change default-true fields to pointers (#44)
Some logically boolean fields default to true. We cannot use bool for these fields, because it defaults to false. So use *bool.
2025-06-25 17:37:45 -04:00
Robert Findley
376d9499d6
README.md: add description to tool input (#38) 2025-06-25 16:57:45 -04:00
Jonathan Amsterdam
92859ef391
mcp: rename LoggingMessage to Log (#42)
Use a verb for this method name.
2025-06-25 16:52:37 -04:00
Gerard Adam
10dcf48fdb
mcp: fix tool result in examples (#45) 2025-06-25 16:48:21 -04:00
Jonathan Amsterdam
600ba61efe
mcp: fix CallToolResultFor[T] unmarshaling (#46)
Add an UnmarshalJSON method for that type.

Add a test.
2025-06-25 16:45:58 -04:00
Robert Jackson
057f525da2
feat(ci): Add check to ensure go fmt has been ran (#43) 2025-06-25 15:31:44 -04:00
Jonathan Amsterdam
09181c2c2e
mcp: use correct ResourceNotFound code (#35) 2025-06-25 14:57:07 -04:00
Sam Thanawalla
1478ba7e0e
design: add design for completion (#34) 2025-06-25 14:56:19 -04:00
qiaodev
abb650e45b
docs: fix README (#32) 2025-06-25 13:54:29 -04:00
Jonathan Amsterdam
1373ddf905
mcp: add a TODO (#31) 2025-06-25 13:19:35 -04:00
Robert Findley
5aabc33c9b
all: minor cleanup and README improvements (#30)
Clean up some inaccurate comments, and update the README to strengthen
warnings about the current status.
2025-06-25 13:12:39 -04:00
Robert Findley
204b59483b
mcp,design: revert 'content' back to an interface type (#29)
After some experience with the flattened version of Content, we see that
it can easily lead to incorrect usage and is a harder API to read.
Therefore, this CL changes back to a design similar to what we had prior
to https://go.dev/cl/672415, though opting to promote content
unmarshalling to the protocol types that use it, which leads to an
overall simpler api.
2025-06-25 13:09:05 -04:00
Robert Findley
d6ea827820
CONTRIBUTING.md: s/steering commitee/working group (#9)
Update the contribution guide to rename 'steering committee' to 'working
group', as approved by counsel. 'Steering committee' was confusing in
the context of MCP, which has its own steering committee.
2025-06-25 09:52:14 -04:00
Jonathan Amsterdam
3da831b0c9
mcp: move to 2025-06-18 schema (#8)
* mcp: move to 2025-06-18 schema

Add types and fields for the latest MCP schema.

The main challenge here was dealing with the presence of _meta fields
on many types, like Tool, Prompt and Resource.

- Distinguish between the _meta field of a request's params, which
  includes a progress token, from the _meta field on other types,
  which is simply a map.

- Redefine GetMeta to return a pointer to the map. We wanted to avoid
  that, but I don't see a clean way to do so. An alternative would be
  to have GetMeta return a map, and SetMeta to set it.

- Provide GetProgressToken for requests only (not notifications or other
  types).

- Still to do: deal with the meta and annotation fields of ContentBlock,
  which are currently duplicated for Resource and ResourceContents.

* Meta and progress token redesign
2025-06-25 09:48:33 -04:00
Robert Findley
735ad517ed
CONTRIBUTING.md: further clarify 'steering committee' (#5)
Futher clarify that the 'steering committee' is what we normally would
call a 'working group', in the preamble to the antitrust policy. We'd
like to also update the policy itself, but need approval from counsel.
2025-06-24 16:23:15 -04:00
Jonathan Amsterdam
9305d6994f
generate.go: remove
Remove the code generator. It has served its purpose.
From now on, we will modify protocol.go directly.
2025-06-23 20:16:40 -04:00
Jonathan Amsterdam
ca88999e6b
mcp, internal/readme: fix go generate (#6)
Adjust paths so `go generate` works.
2025-06-23 15:46:53 -04:00
Jonathan Amsterdam
999ab27343
Minor tweaks to CONTRIBUTING.md (#4)
Minor changes to the contributing doc.
2025-06-23 15:41:25 -04:00
Robert Findley
a60d03e2e3
Merge pull request #3 from modelcontextprotocol/findleyr-patch-1
all: add test github action
2025-06-23 14:57:02 -04:00
Robert Findley
73c9f41c88
all: add test github action
Add a workflow to run Go tests for PRs and pushes to main.
2025-06-23 14:51:04 -04:00
Robert Findley
d45294f9a1
Merge pull request #1 from modelcontextprotocol/findleyr/readme
README: remove toc, update target date
2025-06-23 14:05:57 -04:00
Rob Findley
b3d45d4b53
README: remove toc, update target date
Update the README to remove the table of contents, and update the target
stability date from 'mid July' to 'August': mid July does not allow
enough time for testing.
2025-06-23 17:58:00 +00:00
Rob Findley
658b513c44
all: add go.mod and go.sum file 2025-06-23 17:17:41 +00:00
Rob Findley
26820f8ca8
Initial commit: add LICENSE 2025-06-23 17:17:37 +00:00
Rob Findley
9797d0f3d7 internal/mcp: make parseEventID robust, and add a test
Address comments on CL 682555 about using sscanf for parseEventID,
adding a test for parseEventID and formatEventID.

Change-Id: Ie31c5431c33829eaf244a5927da9e07bf5c300b5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/683336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
2025-06-23 10:15:21 -07:00
Rob Findley
b2b92ae674 internal/mcp: remove stale TODOs in mcp.go
Change-Id: Ia91e9e9c0c94a3e0b511fc14b673ff79ac6affad
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-06-23 06:01:55 -07:00
Rob Findley
4264b03c58 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 <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Bypass: Robert Findley <rfindley@google.com>
Commit-Queue: Robert Findley <rfindley@google.com>
2025-06-20 14:24:49 -07:00
Rob Findley
a590cfe063 internal/mcp: rename StdIO->Stdio
In CL 682976, Alan Donovan correctly points out that the term in the MCP
spec is 'stdio', and therefore the correct capitalization is Stdio.

Change-Id: Ib5bbe04f1a61de886298b4d0adc13aefd6aadd9c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/683075
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-20 13:34:58 -07:00
Rob Findley
f4ed9b5904 internal/mcp: update CONTRIBUTING.md and README.md for the official SDK
Change CONTRIBUTING.md and README.md to reflect that the MCP SDK is
being moved to github.com/modelcontextprotocol/go-sdk, and to include
content from the 'Governance' section of the design doc. Also, include
the antitrust policy as a section in CONTRIBUTING.md.

Change-Id: I46784d8e57b2a2cab8895593f633d20a2e15c8ba
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682976
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-20 13:30:05 -07:00
Jonathan Amsterdam
a6ec3f5f4e internal/mcp: simplify prompt API
Remove NewServerPrompt.

Schema inference is irrelevant for prompts.
All arguments are strings.
So using a struct is not as valuable as with tools.
The only advantage is catching misspellings at compile time.
It's not worth it.

Change-Id: I45aaa5d55c8940cc9e32dc277bd543f79d932519
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682797
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-20 07:28:04 -07:00
Rob Findley
e228d78d19 internal/mcp: provide a customizable http.Client to client transports
Allow customizing the http.Client used for HTTP MCP client transports,
by adding client options structs.

Change-Id: I2297acb136f8d0f7fa70d58cd244a6a81cc89751
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682756
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-19 07:22:49 -07:00
Rob Findley
4012cc3d2e internal/mcp: use JSONRPC aliases consistently
Use JSONRPCMessage, JSONRPCRequest, and JSONRPCResponse aliases
throughout the internal/mcp package, so that no jsonrpc2 names are
exposed in the public API.

Change-Id: Ibce794907538706448c694eafccf599a5892ab17
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2025-06-19 06:55:37 -07:00
Rob Findley
8bc9a9a9f5 internal/jsonrpc2_v2,mcp: remove unneeded dependencies
Remove dependencies on the eventtest and testenv packages from
jsonrpc2_v2 and mcp packages, in preparation for forking.

Change-Id: Id0efb0c3187629f6fb1822cc853ec52acea41b0d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682696
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-18 22:11:26 -07:00
Jonathan Amsterdam
0160cdefa0 internal/mcp: fix prompt example
The hello example was using params.Name, which is the name of the
prompt. It should use args.Name.

Change-Id: I0e7e992bbe312fd5a6e56e9bc46a931f0eeb423c
Reviewed-on: https://go-review.googlesource.com/c/tools/+/682416
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-18 22:02:53 -07:00