Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions examples/servers/typescript/version-negotiation-broken.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env node

/**
* MCP Server with Broken Version Negotiation - Negative Test Case
*
* Blindly echoes whatever protocolVersion the client sends in `initialize`,
* including unsupported versions such as `1999-01-01`.
*
* This server should FAIL the `server-version-negotiate` check in the
* `server-initialize` conformance scenario.
*/

import express from 'express';

const app = express();
app.use(express.json());

app.post('/mcp', (req, res) => {
const body = req.body ?? {};
const id = body.id ?? null;

if (body.method === 'initialize') {
const requestedVersion =
typeof body.params?.protocolVersion === 'string'
? body.params.protocolVersion
: '2025-11-25';

// Broken behavior: echo any requested version without checking support.
res.status(200).json({
jsonrpc: '2.0',
id,
result: {
protocolVersion: requestedVersion,
capabilities: {},
serverInfo: {
name: 'version-negotiation-broken-server',
version: '1.0.0'
}
}
});
return;
}

if (body.method === 'notifications/initialized') {
res.status(202).end();
return;
}

res.status(200).json({
jsonrpc: '2.0',
id,
result: {}
});
});

const PORT = parseInt(process.env.PORT || '3010', 10);
app.listen(PORT, '127.0.0.1', () => {
console.log(
`Broken version negotiation server running on http://localhost:${PORT}/mcp`
);
});
Loading