Overview

πŸš€ MCP Proxy Wrapper

Add hooks and plugins to any MCP server without changing your code

NPM VersionGitHub StarsLicenseTypeScript

npm install mcp-proxy-wrapper

A proxy wrapper that adds hooks, plugins, and custom logic to existing MCP servers without modifying the original code.


🎯 Overview

Add functionality to your existing MCP server:

import { 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.

✨ Key Features

  • πŸ”§ 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

πŸš€ Common Use Cases

const secure = await wrapWithProxy(server, {
  hooks: {
    beforeToolCall: async (context) => {
      if (!await validateApiKey(context.args.apiKey)) {
        return { 
          result: { 
            content: [{ type: 'text', text: 'Unauthorized' }], 
            isError: true 
          }
        };
      }
    }
  }
});

πŸ§ͺ Technical Details

  • 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

πŸš€ Quick Navigation

⭐ Key Features

πŸ”Œ Plugin Architecture

Extensible hook system for beforeToolCall and afterToolCall with zero server modifications.

πŸ€– AI Enhancement Plugins

LLM Summarization and Chat Memory plugins included for intelligent tool enhancement.

πŸ” Authentication & Security

Flexible hook system for implementing access control, rate limiting, and user management.

πŸ“ˆ Analytics & Monitoring

Usage tracking, performance metrics, error reporting, and real-time monitoring capabilities.

🌐 Transport Agnostic

Works with STDIO, WebSocket, SSE, HTTP, and InMemory transport protocols.

🏒 Robust Architecture

Comprehensive error handling, logging, and stable API design.

πŸ”§ How the Proxy Wrapper Works with Tools

πŸ’‘

The proxy wrapper enhances your MCP server without breaking existing functionality - it's completely backward compatible!

  1. Tools registered BEFORE wrapping: Remain fully available and functional, but don't get enhanced with hooks/plugins
  2. Tools registered AFTER wrapping: Get full plugin functionality (summarization, memory, analytics, etc.)
  3. All underlying server functionality: Completely preserved (resources, prompts, metadata, transport)

The proxy wrapper intercepts the server.tool() method registration process, not the tools themselves. So when you call wrapWithProxy(server), it overrides how new tools are registered to add the hook functionality, but existing tools continue to work exactly as before.

πŸ“– This behavior is documented in detail in the Getting Started guide and How It Works section with examples showing the difference between enhanced and non-enhanced tools.

πŸ’» Quick Example

import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { wrapWithProxy, LLMSummarizationPlugin } from 'mcp-proxy-wrapper';
import { z } from 'zod';
 
// Create your MCP server
const server = new McpServer({ name: 'My AI Tools', version: '1.0.0' });
 
// Add AI enhancement plugin
const summarizationPlugin = new LLMSummarizationPlugin();
 
// Wrap with proxy functionality
const proxiedServer = await wrapWithProxy(server, {
  plugins: [summarizationPlugin]
});
 
// Register tools as usual - enhancement happens automatically
proxiedServer.tool('ai-analysis', {
  text: z.string()
}, async (args) => {
  return {
    content: [{ type: 'text', text: `Analysis result: ${args.text}` }]
  };
});

🎯 Get Started


MCP Proxy Wrapper - Add hooks and plugins to any MCP server