Skip to content

fix(mcp): resolve all MCP spec compliance issues#98

Open
giveen wants to merge 2 commits into
mlhher:mainfrom
giveen:bug-fixes
Open

fix(mcp): resolve all MCP spec compliance issues#98
giveen wants to merge 2 commits into
mlhher:mainfrom
giveen:bug-fixes

Conversation

@giveen

@giveen giveen commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description of Changes

  • Replace manual stdio transport with SDK CommandTransport for proper SIGTERM → wait → SIGKILL process lifecycle
  • Reuse single SDK client instance across all server sessions
  • Wire ToolListChangedHandler to re-discover tools on dynamic changes
  • Handle all MCP content types (AudioContent, ResourceLink, EmbeddedResource) plus default warning for unknown types
  • Add SSE and Streamable HTTP transport support for remote servers
  • Capture stderr from stdio subprocesses on connection failure
  • Log warning on config file write failure instead of silent discard
  • Suppress unnecessary 'roots' capability advertisement

Contributor License Agreement (CLA)

To accept your code, we legally need you to agree to our CLA so we can maintain the project's Business Source License (BSL) and future open-source transitions.

  • By checking this box, I confirm that I have read and agree to the terms of the CLA.md in this repository. (To check the box, put an x between the brackets like this: [x])

- Replace manual stdio transport with SDK CommandTransport for proper
  SIGTERM → wait → SIGKILL process lifecycle
- Reuse single SDK client instance across all server sessions
- Wire ToolListChangedHandler to re-discover tools on dynamic changes
- Handle all MCP content types (AudioContent, ResourceLink,
  EmbeddedResource) plus default warning for unknown types
- Add SSE and Streamable HTTP transport support for remote servers
- Capture stderr from stdio subprocesses on connection failure
- Log warning on config file write failure instead of silent discard
- Suppress unnecessary 'roots' capability advertisement
@mlhher

mlhher commented Jul 14, 2026

Copy link
Copy Markdown
Owner

@giveen

Great one thanks!

I evaluated the code a bit and noticed two things that might cause issues, please take a look at them:

  • handleToolListChanged modifies the c.tools map asynchronously, so we need a sync.RWMutex on the Client struct to prevent panics.
  • stderrBuf races because a background routine writes to it while ConnectFromConfig reads it on failure, so we should wrap the buffer with a mutex.

Also a minor thing but would be good to have a tiny time.Sleep before checking the buffer, since an instant failure might read it before the bg routine even writes the error.

Will try this out a little more afterwards and if nothing new pops up it will get merged, thanks!

- Add sync.RWMutex to Client and guard c.tools/c.sessions access in
  Connect, handleToolListChanged, GetTools, GetTool, and Close.
- Wrap ConnectFromConfig's stderr capture buffer in a mutex so the
  background copy goroutine and the failure path no longer race.
- Sleep briefly before reading stderr on failure so the goroutine has
  time to write the error.
@giveen

giveen commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

@mlhher

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