mcp-go
mcp-go copied to clipboard
added the configurable items sse_read_timeout and headers to mcp-client
Added the option design mode to mcp-client and added the configurable items sse_read_timeout and headers. The readSSE() method and sendRequest() method take effect with the SSEMCPClient object, respectively.
When I was looking at Python-sdk, I found that the mcp-client can specify headers and sse_read_timeout configurations when initializing objects. In my usage scenario, it is necessary for the mcp-client object to carry a custom request header. I think this is a universal scenario.
Summary by CodeRabbit
-
New Features
- Introduced configuration options to customize connection headers.
- Added the ability to set a read timeout for Server-Sent Events (SSE) connections.
- Enhanced error handling for scenarios where the SSE read exceeds the specified timeout duration.
-
Changes
- Updated JSON serialization to ensure the
Propertiesfield is always included in the output for theToolInputSchema.
- Updated JSON serialization to ensure the
Walkthrough
The pull request enhances the SSEMCPClient in the client/sse.go file by introducing functional options for configuration, including custom HTTP headers and read timeout settings. The constructor is updated to accept these options, and the SSEMCPClient struct is modified to include new fields. Methods for reading SSE events and sending requests are revised to handle timeout scenarios and integrate custom headers. Additionally, the Properties field in the ToolInputSchema struct in mcp/tools.go is modified to always be included in the JSON output.
Changes
| File(s) | Change Summary |
|---|---|
| client/sse.go | - Added functional options: WithHeaders (to set custom HTTP headers) and WithSSEReadTimeout (to set a custom read timeout).- Modified NewSSEMCPClient to accept variadic options.- Updated SSEMCPClient struct with new fields: headers map[string]string and sseReadTimeout time.Duration.- Updated readSSE to utilize a context with timeout and handle timeout errors.- Enhanced sendRequest to use custom HTTP headers. |
| mcp/tools.go | - Updated Properties field in ToolInputSchema to ensure it is always included in JSON output by changing the JSON tag from json:"properties,omitempty" to json:"properties". |
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 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.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 generate unit testing code.@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.
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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai planto trigger planning for file edits and PR creation.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
I introduced another commit in the current pr, sorry, I'm not familiar with the whole git process.
New submission to solve the problem (https://github.com/junjiem/dify-plugin-agent-mcp_sse/issues/1).
in general, the current MCP - server InputSchema standards do not agree with MCP, Its InputSchema.properties cannot be empty in mcp.
but in mcp-go tool.go
As a result, when I used dify to interconnect with the parameterless tool written based on mcp-go, the mcp-client failed to pass the verification, resulting in an error, namely, the above issues
hi @ezynda3 could you please help check this PR? I hope we can work together as soon as possible. At present, there are already some conflicts. Do you need me to solve them? Thank you very much!
hi @ezynda3 could you please help check this PR? I hope we can work together as soon as possible. At present, there are already some conflicts. Do you need me to solve them? Thank you very much!
Yes please fix the merge conflicts and I can have a look at the PR