ruvnet / ruvnet/ruflo

MCP server sends server.initialized notification before receiving initialize request

Open
#898 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
72.7k
Forks
8.6k
Avg merge
2d 23h
Merged PRs (30d)
83

Description

## Summary

The MCP server sends a `server.initialized` notification immediately on startup, before receiving the `initialize` request from the client. This violates the MCP protocol and causes Claude Code to reject the connection with a Zod validation error.

## Version

- claude-flow: 2.7.42 (alpha)
- Node: v25.2.1
- Platform: macOS arm64

## Reproduction

```bash
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | npx claude-flow@alpha mcp start 2>&1
```

## Observed Output

```
{"jsonrpc":"2.0","method":"server.initialized","params":{"serverInfo":{"name":"claude-flow","version":"2.7.42","capabilities":{"tools":{"listChanged":true},"resources":{"subscribe":true,"listChanged":true}}}}}
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05","capabilities":{"tools":{"listChanged":true},"resources":{"subscribe":true,"listChanged":true}},"serverInfo":{"name":"claude-flow","version":"2.7.42"}}}
```

The `server.initialized` notification (line 1) is sent **before** the server processes the `initialize` request and returns the result (line 2).

## Expected Behavior

Per MCP protocol, the server should:
1. Wait for the `initialize` request
2. Return the `initialize` response
3. Only then may send notifications

The server should not send any messages until it receives the initialize handshake.

## Error in Claude Code

Claude Code rejects the premature notification with:

```
Zod validation error: invalid_union - Required fields missing (id, method, result)
Unrecognized key(s) in object: 'error'
```

This happens because the notification doesn't conform to the expected JSON-RPC response schema during the init phase.

## Workaround

Using `ruv-swarm` as an alternative MCP server for swarm coordination.

Contributor guide

Open the contributing guide

Research direction

Start by running the documented `npx claude-flow@alpha mcp start` reproduction and trace the MCP server's startup and initialize handling. Ensure no message is emitted before the initialize request, then verify that the initialize response is returned before any notification and repeat the Claude Code connection test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.