-
Notifications
You must be signed in to change notification settings - Fork 691
Fix docs #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix docs #430
Conversation
WalkthroughThe documentation examples for HTTP, SSE, STDIO, and in-process MCP transports were updated to use new API patterns, including explicit capability flags, functional options for server configuration, and typed parameter getters. Tool and resource handlers now return JSON strings as text, and client/server initialization uses explicit, structured requests and safer error handling. Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates documentation examples across multiple transports to align with recent API changes, introducing new parameter accessors, result formatting methods, and revised server/client initialization signatures.
- Switch from JSON helpers to
NewToolResultText
with formatted strings and replace direct argument map accesses withGet<Type>
accessors. - Update server and client initialization calls to the new signature, including specifying protocol version and capabilities.
- Refactor SSE and HTTP transport examples to use the new builders (
NewSSEServer
,NewStreamableHTTPServer
), remove deprecated hooks, and standardize resource response types.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
www/docs/pages/transports/stdio.mdx | Updated WithResourceCapabilities , default accessors, and result formatting |
www/docs/pages/transports/sse.mdx | Revised SSE server creation, argument getters, notification API, and result formatting |
www/docs/pages/transports/inprocess.mdx | Adjusted in-process client initialization, parameter getters, and result extraction |
www/docs/pages/transports/http.mdx | Updated HTTP server setup, replaced integer params with number, and reformatted JSON results |
Comments suppressed due to low confidence (1)
www/docs/pages/transports/http.mdx:63
- [nitpick] The helper
mcp.Min
(andmcp.Max
elsewhere) is inconsistent with the earliermcp.Minimum
/mcp.Maximum
naming. Standardize on one convention to avoid confusion.
mcp.WithNumber("age", mcp.Min(0)),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (4)
www/docs/pages/transports/inprocess.mdx (3)
99-104
: Safe text extraction from result
Good practice usingmcp.AsTextContent
. Consider adding anelse
or logging if no content is present to aid debugging.
157-161
: Embedded client creation in Application
Works as written; for consistency with the basic example consider usinglog.Fatal
instead ofpanic
.
225-232
: Consistent safe extraction in ProcessWithMCP
Mirrors the basic example’s content extraction; again, an explicit fallback log or error on emptyContent
could improve clarity.www/docs/pages/transports/http.mdx (1)
222-224
: Usestrings.HasPrefix
over manual slice
Consider replacinguri[:8] == "users://"
withstrings.HasPrefix(uri, "users://")
for clarity.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
www/docs/pages/transports/http.mdx
(8 hunks)www/docs/pages/transports/inprocess.mdx
(8 hunks)www/docs/pages/transports/sse.mdx
(9 hunks)www/docs/pages/transports/stdio.mdx
(12 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: test
🔇 Additional comments (40)
www/docs/pages/transports/inprocess.mdx (7)
59-63
: Client instantiation with error handling
Properly handles errors fromclient.NewInProcessClient
and ensures the client is closed.
68-79
: Explicit Initialize call with functional options
The example now usesmcp.InitializeRequest
with explicit params and checks errors correctly.
85-94
: CallTool invocation uses new request struct
Switched tomcp.CallToolRequest
and explicitCallToolParams
. Error handling remains appropriate.
108-110
: Typed parameter getters in handler
Usingreq.GetString
andreq.GetFloat
improves safety over raw map assertions.
129-129
: Return tool result as text
Consistent use ofmcp.NewToolResultText
for string results.
212-220
: Internal CallTool usage in ProcessWithMCP
Correct adaptation of client call pattern within application context.
246-253
: Initialize embedded MCP client in main
ExplicitInitialize
with error handling matches updated API patterns.www/docs/pages/transports/stdio.mdx (8)
43-44
: Enable explicit resource capabilities
Addedserver.WithResourceCapabilities(true, true)
to align with other transport examples.
55-56
: Boolean parameter default viamcp.DefaultBool
Switch toreq.RequireBool
andmcp.DefaultBool(false)
for safer defaults.
101-103
: Return tool result as text
Now usesmcp.NewToolResultText
with formatted JSON string, consistent with new patterns.
105-124
: Resource handler signature and return type updated
Handler now returns[]mcp.ResourceContents
withTextResourceContents
, aligning with unified API.
208-211
: Advanced STDIO server: explicit capability flags
Replaced generic hooks withWithResourceCapabilities
,WithPromptCapabilities
,WithToolCapabilities
, andWithLogging
.
333-345
: Client initialization in custom integration
Example now shows explicitInitialize
call withInitializeRequest
and error handling.
350-354
: ListTools invocation uses new request struct
Switched toc.ListTools(ctx, mcp.ListToolsRequest{})
.
362-370
: CallTool invocation in custom client
Updated to usemcp.CallToolRequest
and explicitCallToolParams
.www/docs/pages/transports/http.mdx (13)
46-47
: Enable explicit resource capabilities
Addedserver.WithResourceCapabilities(true, true)
alongside tool capabilities for consistency.
63-63
: Switch parameter type toNumber
Changedage
from integer tomcp.WithNumber("age", mcp.Min(0))
to match new API.
73-74
: Pagination params useNumber
with defaults and bounds
limit
andoffset
now usemcp.DefaultNumber
,mcp.Min
, andmcp.Max
.
98-101
: Typed getters for required params in GET handler
req.GetString("user_id", "")
and validation covers missing input.
109-111
: Return user info as text-based JSON
Consistent use ofmcp.NewToolResultText
for JSON string payloads.
114-117
: Typed getters in CreateUser handler
UsingGetString
andGetInt
aligns with other examples.
118-120
: Input validation centralized
Ensuresname
and
140-142
: Return create response as text
Consistent JSON string viamcp.NewToolResultText
.
178-180
: Typed getters in SearchUsers handler
Switch toreq.GetString
,GetInt
with defaults.
188-190
: Return search results as formatted text
Unified result formatting withmcp.NewToolResultText
.
192-206
: Resource handler signature and return type updated
Returns[]mcp.ResourceContents
withTextResourceContents
.
234-237
: Advanced HTTP: explicit capability flags
Replaced deprecated all-capabilities and hooks with targeted flags and logging.
246-250
: Advanced HTTP server options via functional opts
NewWithEndpointPath
,WithHeartbeatInterval
, andWithStateLess
reflect updated streamable server API.www/docs/pages/transports/sse.mdx (12)
42-43
: Enable explicit resource capabilities
Addedserver.WithResourceCapabilities(true, true)
to match other transport examples.
50-51
: Count param usesDefaultNumber
mcp.WithNumber("count", mcp.DefaultNumber(10))
ensures a safe default for streaming loop.
56-58
: Duration param usesDefaultNumber
mcp.WithNumber("duration", mcp.DefaultNumber(60))
standardizes timeout handling.
76-77
: Switch toNewSSEServer
andStart
Refactored fromServeSSE
toserver.NewSSEServer(...).Start
, aligning with other transports.
83-84
: Typed getters in stream handler
req.GetString
andreq.GetInt
improve parameter safety.
86-87
: Retrieve server instance from context
Usingserver.ServerFromContext(ctx)
for notifications is correct and idiomatic.
103-113
: Send progress notifications via MCP server
Properly checksmcpServer != nil
and logs send failures.
118-119
: Return streaming results as text
Unified withmcp.NewToolResultText
for final JSON string.
175-183
: Resource handler updated to slice return type
Now returns[]mcp.ResourceContents
withTextResourceContents
.
192-196
: Advanced SSE: explicit capability flags
Replaced broad hooks with specificWithXCapabilities
and logging.
203-207
: Advanced SSE server options via functional opts
IntroducedWithStaticBasePath
,WithKeepAliveInterval
, andWithBaseURL
options.
236-236
: Default channel parameter viaDefaultString
mcp.WithString("channel", mcp.DefaultString("general"))
matches other transport defaults.
Description
Fixes #<issue_number> (if applicable)
Type of Change
Checklist
MCP Spec Compliance
Additional Information
Summary by CodeRabbit