modelcontextprotocol / modelcontextprotocol/python-sdk

Add conveniences for MCP proxy pattern

Open
#12 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P1 v2
Dominant language
Python
Stars
24.3k
Forks
4k
Avg merge
1d 1h
Merged PRs (30d)
31

Description

TypeScript example, but should also be portable to our Python SDK:

export function mcpProxy({
  transportToClient,
  transportToServer,
  onerror,
}: {
  transportToClient: Transport;
  transportToServer: Transport;
  onerror: (error: Error) => void;
}) {
  transportToClient.onmessage = (message) => {
    transportToServer.send(message).catch(onerror);
  };

  transportToServer.onmessage = (message) => {
    transportToClient.send(message).catch(onerror);
  };

  transportToClient.onclose = () => {
    transportToServer.close().catch(onerror);
  };

  transportToServer.onclose = () => {
    transportToClient.close().catch(onerror);
  };

  transportToClient.onerror = onerror;
  transportToServer.onerror = onerror;
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Python SDK's transport abstractions and the client or server entry points where a proxy could be exposed, then compare them with the TypeScript example in the issue. Done should provide equivalent bidirectional message forwarding, error handling, and close propagation, with the relevant Python tests updated or added.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, typescript
Domain
api, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.