Skip to content

Conversation

@findleyr
Copy link
Contributor

@findleyr findleyr commented Sep 12, 2025

Add a framework for feature documentation, and start populating it with
our SDK documentation.

This framework is as follows:

  • internal/docs/**.src.md is the markdown source for the docs/
    directory.
  • The x/example/internal/cmd/weave tool is used to compile these docs to
    the top-level docs, supporting both linked code samples and generated
    tables of contents.
  • The readme-check workflow is updated to check these docs as well.
  • The structure of these docs follows the MCP spec.
  • Wherever possible, example code is linked from actual Go documentation
    examples, so that it is testable.

Some minor modifications to the weave tool were made to support this
framework.

Additionally, partially fill out this documentation with content on
base protocol and client features, as well as troubleshooting help.

Along the way, a bug was encountered that our LoggingTransport was not
concurrency safe. This is fixed with a mutex.

Fixes #466
Fixes #409
Updates #442

@findleyr findleyr force-pushed the features branch 3 times, most recently from 793be74 to 3a76d85 Compare September 15, 2025 20:26
@findleyr
Copy link
Contributor Author

There are a lot of lines in this CL, but many of them are duplicate.

Things to review:

  • Review the go:generate directives in internal/docs/doc.go, as well as readme-check.yml to understand the framework.
  • Carefully review the non-test changes to the mcp package.
  • Consider the pattern for extracting examples to docs, and agree/disagree.
  • Review the documentation in the docs/, which contains the examples along with prose.

Thanks!

P.S. I didn't get to everything, but the CL was already getting quite large, so we should review it.

@findleyr findleyr marked this pull request as ready for review September 15, 2025 20:30
Add a framework for feature documentation, and start populating it with
our SDK documentation.

This framework is as follows:
- internal/docs/**.src.md is the markdown source for the docs/
  directory.
- The x/example/internal/cmd/weave tool is used to compile these docs to
  the top-level docs, supporting both linked code samples and generated
  tables of contents.
- The readme-check workflow is updated to check these docs as well.
- The structure of these docs follows the MCP spec.
- Wherever possible, example code is linked from actual Go documentation
  examples, so that it is testable.

Some minor modifications to the weave tool were made to support this
framework.

Additionally, partially fill out this documentation with content on
base protocol and client features, as well as troubleshooting help.

Along the way, a bug was encountered that our LoggingTransport was not
concurrency safe. This is fixed with a mutex.

Fixes modelcontextprotocol#466
Fixes modelcontextprotocol#409
Updates modelcontextprotocol#442
jba
jba previously requested changes Sep 16, 2025
transport := &mcp.StreamableClientTransport{
Endpoint: "http://localhost:8080/mcp",
}
client, err := mcp.Connect(context.Background(), transport, &mcp.ClientOptions{...})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use ctx here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

```go
ctx, cancel := context.WithCancel(context.Background())
go cs.CallTool(ctx, &CallToolParams{Name: "slow"})
cancel() // cancel the tool call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't make sense. Add more code or at least "...".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a full example.

@jba
Copy link
Contributor

jba commented Sep 16, 2025

This is awesome, BTW.

@jba jba dismissed their stale review September 16, 2025 15:13

get it in

@jba jba merged commit ac2f175 into modelcontextprotocol:main Sep 16, 2025
6 checks passed
@findleyr findleyr deleted the features branch September 25, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Logging transport should be concurrency safe Add a troubleshooting guide

3 participants