Skip to content

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

Merged
merged 1 commit into from
Jun 21, 2025
Merged

Fix docs #430

merged 1 commit into from
Jun 21, 2025

Conversation

ezynda3
Copy link
Contributor

@ezynda3 ezynda3 commented Jun 21, 2025

Description

Fixes #<issue_number> (if applicable)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • MCP spec compatibility implementation
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring (no functional changes)
  • Performance improvement
  • Tests only (no functional changes)
  • Other (please describe):

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the documentation accordingly

MCP Spec Compliance

  • This PR implements a feature defined in the MCP specification
  • Link to relevant spec section: Link text
  • Implementation follows the specification exactly

Additional Information

Summary by CodeRabbit

  • Documentation
    • Updated all transport protocol documentation examples (HTTP, in-process, SSE, STDIO) to reflect new API patterns and improved parameter handling.
    • Standardized server initialization, tool parameter extraction, and response formatting across all examples.
    • Enhanced error handling, type safety, and unified result formatting to use JSON strings in tool results.
    • Simplified server configuration and logging setup in advanced examples for clarity and consistency.

Copy link
Contributor

coderabbitai bot commented Jun 21, 2025

Walkthrough

The 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

Files Change Summary
www/docs/pages/transports/http.mdx Updated StreamableHTTP server and handler examples: switched to explicit capability flags, typed parameter getters, JSON string text results, new resource handler signatures, simplified URI parsing, and removed helper functions. Server configuration now uses functional options instead of option structs.
www/docs/pages/transports/inprocess.mdx Updated in-process client usage: now requires explicit error handling, detailed initialization, typed parameter extraction, safer result extraction, and text-based JSON responses. Embedded application and handler logic updated to match new API patterns.
www/docs/pages/transports/sse.mdx Updated SSE server and handler examples: explicit capability flags, functional options for server configuration, use of server instance for notification sending, typed parameter getters, text-based JSON results, and simplified documentation for session and notification management.
www/docs/pages/transports/stdio.mdx Updated STDIO server/client examples: explicit capability flags, typed parameter getters, text-based JSON results, safer error handling, structured client initialization, and simplified logging setup. Resource handler signature updated to return a slice of contents.

Possibly related PRs

  • mark3labs/mcp-go#273: Implements the StreamableHTTPServer with its configuration, session management, and HTTP handling logic, directly related to documentation updates using this new API.
  • mark3labs/mcp-go#322: Updates handler implementations to use typed getter methods for parameter extraction and return MCP tool result errors, matching the main PR's handler changes.
  • mark3labs/mcp-go#114: Refactors the MCP client to unify transport layers, including StreamableHTTP, aligning with the server-side example updates in this PR.

Suggested labels

documentation

Suggested reviewers

  • robert-jackson-glean

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@Copilot Copilot AI left a 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 with Get<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 (and mcp.Max elsewhere) is inconsistent with the earlier mcp.Minimum/mcp.Maximum naming. Standardize on one convention to avoid confusion.
            mcp.WithNumber("age", mcp.Min(0)),

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 using mcp.AsTextContent. Consider adding an else 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 using log.Fatal instead of panic.


225-232: Consistent safe extraction in ProcessWithMCP
Mirrors the basic example’s content extraction; again, an explicit fallback log or error on empty Content could improve clarity.

www/docs/pages/transports/http.mdx (1)

222-224: Use strings.HasPrefix over manual slice
Consider replacing uri[:8] == "users://" with strings.HasPrefix(uri, "users://") for clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fdb197 and aa73464.

📒 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 from client.NewInProcessClient and ensures the client is closed.


68-79: Explicit Initialize call with functional options
The example now uses mcp.InitializeRequest with explicit params and checks errors correctly.


85-94: CallTool invocation uses new request struct
Switched to mcp.CallToolRequest and explicit CallToolParams. Error handling remains appropriate.


108-110: Typed parameter getters in handler
Using req.GetString and req.GetFloat improves safety over raw map assertions.


129-129: Return tool result as text
Consistent use of mcp.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
Explicit Initialize with error handling matches updated API patterns.

www/docs/pages/transports/stdio.mdx (8)

43-44: Enable explicit resource capabilities
Added server.WithResourceCapabilities(true, true) to align with other transport examples.


55-56: Boolean parameter default via mcp.DefaultBool
Switch to req.RequireBool and mcp.DefaultBool(false) for safer defaults.


101-103: Return tool result as text
Now uses mcp.NewToolResultText with formatted JSON string, consistent with new patterns.


105-124: Resource handler signature and return type updated
Handler now returns []mcp.ResourceContents with TextResourceContents, aligning with unified API.


208-211: Advanced STDIO server: explicit capability flags
Replaced generic hooks with WithResourceCapabilities, WithPromptCapabilities, WithToolCapabilities, and WithLogging.


333-345: Client initialization in custom integration
Example now shows explicit Initialize call with InitializeRequest and error handling.


350-354: ListTools invocation uses new request struct
Switched to c.ListTools(ctx, mcp.ListToolsRequest{}).


362-370: CallTool invocation in custom client
Updated to use mcp.CallToolRequest and explicit CallToolParams.

www/docs/pages/transports/http.mdx (13)

46-47: Enable explicit resource capabilities
Added server.WithResourceCapabilities(true, true) alongside tool capabilities for consistency.


63-63: Switch parameter type to Number
Changed age from integer to mcp.WithNumber("age", mcp.Min(0)) to match new API.


73-74: Pagination params use Number with defaults and bounds
limit and offset now use mcp.DefaultNumber, mcp.Min, and mcp.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 of mcp.NewToolResultText for JSON string payloads.


114-117: Typed getters in CreateUser handler
Using GetString and GetInt aligns with other examples.


118-120: Input validation centralized
Ensures name and email are provided before proceeding.


140-142: Return create response as text
Consistent JSON string via mcp.NewToolResultText.


178-180: Typed getters in SearchUsers handler
Switch to req.GetString, GetInt with defaults.


188-190: Return search results as formatted text
Unified result formatting with mcp.NewToolResultText.


192-206: Resource handler signature and return type updated
Returns []mcp.ResourceContents with TextResourceContents.


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
New WithEndpointPath, WithHeartbeatInterval, and WithStateLess reflect updated streamable server API.

www/docs/pages/transports/sse.mdx (12)

42-43: Enable explicit resource capabilities
Added server.WithResourceCapabilities(true, true) to match other transport examples.


50-51: Count param uses DefaultNumber
mcp.WithNumber("count", mcp.DefaultNumber(10)) ensures a safe default for streaming loop.


56-58: Duration param uses DefaultNumber
mcp.WithNumber("duration", mcp.DefaultNumber(60)) standardizes timeout handling.


76-77: Switch to NewSSEServer and Start
Refactored from ServeSSE to server.NewSSEServer(...).Start, aligning with other transports.


83-84: Typed getters in stream handler
req.GetString and req.GetInt improve parameter safety.


86-87: Retrieve server instance from context
Using server.ServerFromContext(ctx) for notifications is correct and idiomatic.


103-113: Send progress notifications via MCP server
Properly checks mcpServer != nil and logs send failures.


118-119: Return streaming results as text
Unified with mcp.NewToolResultText for final JSON string.


175-183: Resource handler updated to slice return type
Now returns []mcp.ResourceContents with TextResourceContents.


192-196: Advanced SSE: explicit capability flags
Replaced broad hooks with specific WithXCapabilities and logging.


203-207: Advanced SSE server options via functional opts
Introduced WithStaticBasePath, WithKeepAliveInterval, and WithBaseURL options.


236-236: Default channel parameter via DefaultString
mcp.WithString("channel", mcp.DefaultString("general")) matches other transport defaults.

@ezynda3 ezynda3 merged commit 8f5b048 into main Jun 21, 2025
4 checks passed
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.

2 participants