Skip to content

fix(mcp): add titleFixWriter for Windsurf stdio compatibility#104

Merged
yoanbernabeu merged 1 commit intoyoanbernabeu:mainfrom
cmdaltctr:fix/mcp-global-mode
Feb 9, 2026
Merged

fix(mcp): add titleFixWriter for Windsurf stdio compatibility#104
yoanbernabeu merged 1 commit intoyoanbernabeu:mainfrom
cmdaltctr:fix/mcp-global-mode

Conversation

@cmdaltctr
Copy link
Copy Markdown
Contributor

@cmdaltctr cmdaltctr commented Feb 4, 2026

This PR adds a titleFixWriter that wraps stdout in the MCP server to fix three issues with Windsurf (and potentially other IDE) integration:

  1. Missing newline after JSON-RPC responses — The default server.ServeStdio writes JSON without a trailing newline. Clients relying on line-delimited JSON-RPC (like Windsurf) hang waiting for the message to complete.
  2. Tool title in wrong location — Windsurf expects title at the tool root level, but mcp-go places it inside annotations. The writer moves it to the correct location.
  3. Missing $schema in inputSchema — Windsurf requires $schema for tool discovery. The writer injects it if absent.

Changes from previous version

This PR was previously scoped to also include a global-mode fallback for mcp-serve. That has been dropped since the upstream --workspace flag (#100) and resolveMCPTarget provide a better solution. This PR now focuses solely on the titleFixWriter fix in mcp/server.go.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 6, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.36%. Comparing base (a322537) to head (2073bc7).
⚠️ Report is 64 commits behind head on main.

Files with missing lines Patch % Lines
mcp/server.go 0.00% 25 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #104      +/-   ##
==========================================
+ Coverage   27.16%   32.36%   +5.20%     
==========================================
  Files          32       40       +8     
  Lines        3711     6303    +2592     
==========================================
+ Hits         1008     2040    +1032     
- Misses       2620     4094    +1474     
- Partials       83      169      +86     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yoanbernabeu
Copy link
Copy Markdown
Owner

Hi @cmdaltctr, thanks for this contribution!

The PR currently has merge conflicts with main. Could you rebase your branch on the latest main to resolve them?

Everything else looks good — CI is green (only codecov/patch fails due to coverage on new code, which is not blocking). We'll be happy to merge once the conflicts are resolved!

Replace server.ServeStdio with a custom titleFixWriter that wraps
stdout to fix three issues with Windsurf MCP integration:

1. Missing newline after JSON-RPC responses (causes client to hang)
2. Move tool title from annotations to root level (Windsurf expects it there)
3. Add $schema to inputSchema (required by Windsurf for tool discovery)
@cmdaltctr cmdaltctr force-pushed the fix/mcp-global-mode branch from f94acf6 to 2073bc7 Compare February 7, 2026 18:02
@cmdaltctr cmdaltctr changed the title fix(mcp): add missing newline and support global mode fallback fix(mcp): add titleFixWriter for Windsurf stdio compatibility Feb 7, 2026
@cmdaltctr
Copy link
Copy Markdown
Contributor Author

Hi @yoanbernabeu, thanks for the review!

I've rebased onto the latest main and scoped down the PR to focus only on the titleFixWriter fix in mcp/server.go.

The global-mode fallback logic I originally included in cli/mcp_serve.go has been dropped — the --workspace flag and resolveMCPTarget from #100 provide a much better solution for that use case.

What remains is a single focused change: replacing server.ServeStdio with a custom writer that fixes three Windsurf compatibility issues (missing newline, title placement, $schema injection).

@yoanbernabeu yoanbernabeu merged commit 0c9d177 into yoanbernabeu:main Feb 9, 2026
9 of 10 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