Add hooks and plugins to any MCP server without changing your code
π Complete Documentation β’ π Quick Start β’ π Plugins β’ ποΈ Examples
A proxy wrapper that adds hooks, plugins, and custom logic to existing MCP servers without modifying the original code.
npm install mcp-proxy-wrapperCreate a wrapped MCP server and configure it in Claude:
// server.js
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { wrapWithProxy, LLMSummarizationPlugin } from 'mcp-proxy-wrapper';
const server = new McpServer({ name: 'Enhanced Server', version: '1.0.0' });
// Add your tools
server.tool('getData', schema, getData);
// Add proxy wrapper with plugins
const plugin = new LLMSummarizationPlugin();
plugin.updateConfig({
options: {
provider: 'openai',
openaiApiKey: process.env.OPENAI_API_KEY
}
});
const enhanced = await wrapWithProxy(server, {
plugins: [plugin],
hooks: {
beforeToolCall: async (context) => {
console.log(`π§ ${context.toolName}`);
}
}
});
// Start the server
enhanced.start(process.stdin, process.stdout);Then add to Claude Code:
# Add to local project
claude mcp add enhanced-server node /path/to/server.js
# Add to all projects (user scope)
claude mcp add enhanced-server --scope user node /path/to/server.js
# Add to team projects (project scope)
claude mcp add enhanced-server --scope project node /path/to/server.jsEnhance existing MCP servers without modification:
// proxy-server.js
import { createStdioServerProxy, LLMSummarizationPlugin } from 'mcp-proxy-wrapper';
const plugin = new LLMSummarizationPlugin();
plugin.updateConfig({
options: { openaiApiKey: process.env.OPENAI_API_KEY }
});
// Proxy an existing server and add features
const proxy = await createStdioServerProxy({
command: 'npx',
args: ['@modelcontextprotocol/server-filesystem', '/tmp'],
plugins: [plugin],
hooks: {
beforeToolCall: async (context) => {
// Add authentication, logging, etc.
console.log(`Tool called: ${context.toolName}`);
}
}
});
proxy.start(process.stdin, process.stdout);Configure in Claude Code:
claude mcp add filesystem-enhanced node /path/to/proxy-server.jsimport { wrapWithProxy, LLMSummarizationPlugin } from 'mcp-proxy-wrapper';
// Your existing server - no changes needed
const server = new McpServer({ name: 'My Server', version: '1.0.0' });
server.tool('getData', schema, getData);
// Add plugins and hooks
const plugin = new LLMSummarizationPlugin();
plugin.updateConfig({
options: {
provider: 'openai',
openaiApiKey: process.env.OPENAI_API_KEY
}
});
const enhanced = await wrapWithProxy(server, {
plugins: [plugin],
hooks: {
beforeToolCall: async (context) => {
console.log(`π§ ${context.toolName}`);
// Add auth, rate limiting, etc.
}
}
});Result: Your server now has AI summarization, logging, and custom hooks without any code changes.
- π§ Zero Code Changes - Wrap existing servers instantly
- π€ AI Integration - OpenAI-powered response summarization
- πͺ Hook System - beforeToolCall/afterToolCall with full control
- π Plugin Architecture - Reusable, composable functionality
- π Remote Servers - Proxy external MCP servers over HTTP/WebSocket
- π‘οΈ Authentication & Security - Auth, rate limiting, access control patterns
- π Comprehensive Tests - 273 tests covering MCP protocol compatibility
const secure = await wrapWithProxy(server, {
hooks: {
beforeToolCall: async (context) => {
if (!await validateApiKey(context.args.apiKey)) {
return { result: { content: [{ type: 'text', text: 'Unauthorized' }], isError: true }};
}
}
}
});const plugin = new LLMSummarizationPlugin();
plugin.updateConfig({
options: {
provider: 'openai',
openaiApiKey: process.env.OPENAI_API_KEY,
summarizeTools: ['research', 'analyze']
}
});
const intelligent = await wrapWithProxy(server, {
plugins: [plugin]
});// Proxy external servers and add features
const plugin = new LLMSummarizationPlugin();
plugin.updateConfig({
options: {
provider: 'openai',
openaiApiKey: process.env.OPENAI_API_KEY
}
});
const proxy = await createHttpServerProxy('https://api.example.com/mcp', {
plugins: [plugin],
hooks: { /* your custom logic */ }
});- 273 passing tests with real MCP client-server communication
- Comprehensive error handling with fallbacks and proper error propagation
- TypeScript native with full type safety and IntelliSense
- MCP SDK v1.6.0+ compatible with any existing server
π Complete Documentation β
- π Getting Started - Step-by-step setup guide
- π§ How It Works - Understanding the proxy
- π Plugin System - Build and use plugins
- π API Reference - Complete API docs
- ποΈ Examples - Real-world examples
- π Deployment - Deployment guide
Contributions welcome! See Contributing Guide for details.
git clone https://github.com/mcp-plugins/mcp-proxy-wrapper.git
cd mcp-proxy-wrapper && npm install && npm testMIT License - see LICENSE file for details.