Skip to content

Conversation

@wzxxing
Copy link
Contributor

@wzxxing wzxxing commented Dec 4, 2025

Summary

Clients such ClaudeCode, Cursor, mcp inspector considers the connection as functional as long as the initialize request is successful, even if the following request to list tools, list template, list resources all fail due to the connection to remote cannot be established.

This PR connects to the client immediately in the fastmcp middleware on_initialize method so that the stdio initialize request fails early, instead of showing as a function but with no capabilities.

Changes

Please provide a summary of what's being changed

  1. initialize immediately in the middleware upon stdio client sends initialize request. feat: handle error from the initialize middleware jlowin/fastmcp#2531
  2. patch fastmcp so that the errors in initialize method can be raised back to the client
  3. avoid calling _connect for kiro cli, because it does not handle initialize error well due to rust sdk fix: use the json rpc error from the initialize response and bubble up to the client modelcontextprotocol/rust-sdk#569

User experience

Please share what the user experience looks like before and after this change

ClaudeCode and Cursor experience is fixed. Currently for ClaudeCode and Cursor, the protocol initialization succeeds, but list-tools fail, which lead to the MCP server is shown as connected, but no capabilities.

Checklist

If your change doesn't seem to apply, please leave them unchecked.

  • I have reviewed the contributing guidelines
  • I have performed a self-review of this change
  • Changes have been tested
  • Changes are documented

Is this a breaking change? (Y/N)

  • Yes
  • No

Please add details about how this change was tested.

  • Did integration tests succeed?
  • If the feature is a new use case, is it necessary to add a new integration test case?

Acknowledgment

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@wzxxing wzxxing requested a review from a team as a code owner December 4, 2025 12:53
@wzxxing wzxxing requested review from acmlau and zdwheels December 4, 2025 12:53
@wzxxing wzxxing force-pushed the connect-immediately branch 4 times, most recently from 3745d89 to d4ccac1 Compare December 4, 2025 13:55
@wzxxing wzxxing force-pushed the connect-immediately branch from d4ccac1 to fb9afeb Compare December 4, 2025 13:58
@wzxxing wzxxing merged commit 62118f8 into aws:main Dec 4, 2025
3 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.

3 participants