MCP ExplorerExplorer

Punkpeye Mcp Proxy

@MCP-Mirroron 10 months ago
1 BSD-2-Clause
FreeCommunity
AI Systems
Mirror of https://github.com/punkpeye/mcp-proxy

Overview

What is Punkpeye Mcp Proxy

punkpeye_mcp-proxy is a TypeScript-based Server-Sent Events (SSE) proxy designed for MCP servers that utilize stdio transport. It facilitates communication between clients and servers by forwarding messages efficiently.

Use cases

Use cases for punkpeye_mcp-proxy include building real-time applications such as chat systems, live notifications, and data visualization tools that require efficient message forwarding and event handling.

How to use

To use punkpeye_mcp-proxy, install it via npm with ‘npm install mcp-proxy’. You can start the proxy server using the command ‘npx mcp-proxy --port 8080 --endpoint /sse tsx server.js’, which sets up an SSE server on port 8080.

Key features

Key features of punkpeye_mcp-proxy include the ability to set up a proxy server, start an SSE server, and tap into transport to log events. It provides a straightforward API for creating proxies between servers and clients.

Where to use

punkpeye_mcp-proxy can be used in web applications that require real-time data streaming and communication between clients and servers, particularly in environments utilizing the MCP protocol.

Content

MCP Proxy

A TypeScript SSE proxy for MCP servers that use stdio transport.

[!NOTE]
For a Python implementation, see mcp-proxy.

[!NOTE]
MCP Proxy is what FastMCP uses to enable SSE.

Installation

npm install mcp-proxy

Quickstart

Command-line

npx mcp-proxy --port 8080 --endpoint /sse tsx server.js

This starts an SSE server and stdio server (tsx server.js). The SSE server listens on port 8080 and endpoint /sse, and forwards messages to the stdio server.

Node.js SDK

The Node.js SDK provides several utilities that are used to create a proxy.

proxyServer

Sets up a proxy between a server and a client.

const transport = new StdioClientTransport();
const client = new Client();

const server = new Server(serverVersion, {
  capabilities: {},
});

proxyServer({
  server,
  client,
  capabilities: {},
});

In this example, the server will proxy all requests to the client and vice versa.

startSSEServer

Starts a proxy that listens on a port and endpoint, and sends messages to the attached server via SSEServerTransport.

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { startSSEServer } from "mcp-proxy";

const { close } = await startSSEServer({
  port: 8080,
  endpoint: "/sse",
  createServer: async () => {
    return new Server();
  },
});

close();

tapTransport

Taps into a transport and logs events.

import { tapTransport } from "mcp-proxy";

const transport = tapTransport(new StdioClientTransport(), (event) => {
  console.log(event);
});

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers