Skip to content

[BUG] Incompatible with VS Code MCP Client - outdated @modelcontextprotocol/sdk uses newline-delimited JSON instead of Content-Length framing #34

@LukasSteindl

Description

@LukasSteindl

Description

obsidian-mcp v1.0.6 uses @modelcontextprotocol/sdk@^1.0.4, which implements newline-delimited JSON transport over stdio. However, VS Code's built-in MCP client (and other modern MCP hosts) use Content-Length framing (LSP-style headers), as specified in the current MCP transport spec.

This means the server starts successfully and registers all tools, but never responds to the client's initialize request, because the ReadBuffer in the bundled SDK tries to JSON.parse("Content-Length: 160\r") and throws a SyntaxError.

Root Cause

The bundled @modelcontextprotocol/sdk v1.0.4 ReadBuffer.readMessage() splits on \n and passes the line directly to JSON.parse():

readMessage() {
  const index = this._buffer.indexOf('\n');
  const line = this._buffer.toString("utf8", 0, index);
  return deserializeMessage(line); // JSON.parse(line)
}

When the client sends:

Content-Length: 160\r\n\r\n{"jsonrpc":"2.0","id":1,"method":"initialize",...}

The buffer finds \n in the header line and tries to parse "Content-Length: 160\r" as JSON → SyntaxError.

Reproduction

  1. Configure in VS Code mcp.json:
"obsidian": {
  "type": "stdio",
  "command": "npx",
  "args": ["-y", "obsidian-mcp", "D:\\obsidianvault"]
}
  1. Server starts, registers tools (visible in stderr)
  2. VS Code sends initialize → server crashes with:
Server error: SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at deserializeMessage (.../obsidian-mcp/build/main.js:11734:42)

Verification

Sending newline-delimited JSON directly works fine:

// This works:
p.stdin.write(JSON.stringify(initRequest) + '\n');
// → Server responds correctly with protocolVersion, capabilities, etc.

Suggested Fix

Update @modelcontextprotocol/sdk from ^1.0.4 to a current version (latest is 1.27.0). The newer SDK handles both Content-Length framing and newline-delimited JSON.

Environment

  • OS: Windows 11
  • VS Code: latest (Feb 2026)
  • Node.js: v24.11.1
  • obsidian-mcp: 1.0.6 (latest on npm)
  • Bundled MCP SDK: 1.0.4

Related Issues

These issues likely share the same root cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions