read-mcp-sse
v1.1.1
Published
the tool taht read mcp server by sse url
Downloads
3
Readme
read-mcp-sse
A tool for reading MCP (Message Control Protocol) server through SSE (Server-Sent Events) URL. This library allows you to:
- Connect to an MCP server via SSE
- Retrieve a list of available MCP methods
- Call MCP methods with parameters
- Receive real-time updates through the SSE connection
Installation
npm install read-mcp-sseUsage
Basic Example
import { McpSseReader } from 'read-mcp-sse';
// Create an instance with your MCP SSE URL
const mcpReader = new McpSseReader('http://your-mcp-server/sse');
// Get available methods
mcpReader.getMethods()
.then(methods => {
console.log('Available methods:', methods);
// Call a method
return mcpReader.callMethod('methodName', { param1: 'value1' });
})
.then(result => {
console.log('Method call result:', result);
})
.catch(error => {
console.error('Error:', error);
})
.finally(() => {
// Close the connection when done
mcpReader.close();
});Advanced Example
See the example.ts file for a more detailed example.
API
McpSseReader
Constructor
constructor(mcpProxySseUrl: string)mcpProxySseUrl: The SSE URL of the MCP server
Methods
waitForConnection(): Returns a Promise that resolves when the connection is establishedgetMethods(): Returns a Promise with the list of available MCP methodscallMethod(methodName: string, params: any = {}): Calls an MCP method with the provided parametersclose(): Closes the SSE connection
License
MIT
