mcp-http-proxy

akhshyganesh/mcp-http-proxy

3.2

If you are the rightful owner of mcp-http-proxy and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The MCP HTTP Proxy is a robust server designed to facilitate HTTP request proxying for AI applications, ensuring secure and structured communication with external APIs.

๐ŸŒ MCP HTTP Proxy

A powerful Model Context Protocol (MCP) server that provides HTTP request proxying for AI applications. All responses are structured for AI consumption with consistent status, data, and error fields.


๐Ÿ“‹ Repository Information

FieldValue
๐Ÿ”— GitHubakhshyganesh/mcp-http-proxy
๐Ÿ‘ค AuthorAkhshy Ganesh (akhshy.balakannan@gmail.com)
๐Ÿ“„ LicenseMIT License
๐Ÿ”– Version1.0.0
๐Ÿ“ฆ Packagemcp-http-proxy

๐Ÿค– What is MCP?

The Model Context Protocol (MCP) is an open standard that enables secure connections between AI applications and external data sources. This server implements MCP to provide AI assistants with the ability to perform HTTP operations against external APIs through a standardized interface.


โœจ Features

  • ๐ŸŒ HTTP Request Proxying: Support for GET, POST, PUT, DELETE methods to external APIs
  • ๐Ÿ–ฅ๏ธ Curl Proxy: Uses system curl commands to communicate with target servers
  • ๐Ÿค– AI-Friendly Responses: Structured JSON responses with status, HTTP code, data, and error fields
  • ๐Ÿ›ก๏ธ Intelligent Error Handling: Provides helpful guidance for common HTTP errors (401, 403, 429, etc.)
  • โœ… Schema Validation: Input validation using Zod schemas
  • ๐Ÿ”’ Security: Built-in timeout protection and input sanitization to prevent command injection
  • ๐Ÿ“˜ TypeScript: Fully typed implementation with the MCP SDK

๐Ÿ—๏ธ Architecture

graph LR
    A[AI Assistant] <--> B[MCP Client]
    B <--> C[This MCP Server]
    C <--> D[Curl]
    D <--> E[Target API Server]

The server receives MCP requests, validates input, constructs curl commands, executes them, and returns structured responses.

๐Ÿš€ Installation & Setup

๐Ÿ“ฆ For End Users (Recommended)

Option 1: Install from NPM (Easiest)
# Install globally to use anywhere
npm install -g mcp-http-proxy

# Start the server
mcp-http-proxy
Option 2: Install from GitHub
# Install directly from the repository
npm install -g git+https://github.com/akhshyganesh/mcp-http-proxy.git

# Start the server
mcp-http-proxy
Option 3: Use with npx (No Installation)
# Run directly without installing
npx mcp-http-proxy

๐Ÿ› ๏ธ For Developers

1๏ธโƒฃ Clone and Install Dependencies
git clone https://github.com/akhshyganesh/mcp-http-proxy.git
cd mcp-http-proxy
npm install
2๏ธโƒฃ Build the Project
npm run build
3๏ธโƒฃ Start the Server
npm start
# or for development with auto-reload
npm run dev

๐Ÿ”ง MCP Client Configuration

Once installed, you can use this server with any MCP-compatible client. Here are example configurations:

Claude Desktop Configuration

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "mcp-http-proxy": {
      "command": "mcp-http-proxy"
    }
  }
}

VS Code MCP Extension

Add to your .vscode/mcp.json:

{
  "mcpServers": {
    "mcp-http-proxy": {
      "command": "mcp-http-proxy"
    }
  }
}

๐Ÿ› ๏ธ Development

๐Ÿ“œ Available Scripts

CommandDescription
npm run build๐Ÿ”จ Compile TypeScript to JavaScript
npm startโ–ถ๏ธ Start the compiled server
npm run dev๐Ÿ‘€ Watch mode for development (auto-recompile on changes)
npm run clean๐Ÿงน Remove compiled files
npm test๐Ÿงช Run test suite
npm run test:watch๐Ÿ” Run tests in watch mode
npm run test:coverage๐Ÿ“Š Run tests with coverage report
npm run lint๐Ÿ” Check code style and quality
npm run lint:fix๐Ÿ”ง Fix linting issues automatically

๐Ÿ“ Project Structure

โ”œโ”€โ”€ ๐Ÿ“‚ src/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ index.ts              # Main MCP server implementation
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ @types/               # Custom type declarations
โ”‚       โ””โ”€โ”€ ๐Ÿ“„ modelcontextprotocol__sdk.d.ts
โ”œโ”€โ”€ ๐Ÿ“‚ tests/                    # Test files
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ server.test.ts        # Server functionality tests
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ setup.ts              # Test setup configuration
โ”œโ”€โ”€ ๐Ÿ“‚ dist/                     # Compiled JavaScript (generated, not tracked)
โ”œโ”€โ”€ ๐Ÿ“‚ .vscode/
โ”‚   โ”œโ”€โ”€ ๐Ÿ“„ mcp.json             # VS Code MCP integration config
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ tasks.json           # VS Code build tasks
โ”œโ”€โ”€ ๐Ÿ“‚ .github/
โ”‚   โ””โ”€โ”€ ๐Ÿ“‚ workflows/
โ”‚       โ””โ”€โ”€ ๐Ÿ“„ ci.yml           # Continuous Integration pipeline
โ”œโ”€โ”€ ๐Ÿ“„ jest.config.js           # Jest testing configuration
โ”œโ”€โ”€ ๐Ÿ“„ .eslintrc.js             # ESLint configuration
โ”œโ”€โ”€ ๐Ÿ“„ .npmignore               # NPM package exclusions
โ”‚   โ””โ”€โ”€ ๐Ÿ“„ copilot-instructions.md # GitHub Copilot workspace instructions
โ”œโ”€โ”€ ๐Ÿ“„ test-requests.json        # Sample test requests
โ”œโ”€โ”€ ๐Ÿ“„ test-requests.md          # Test requests documentation
โ”œโ”€โ”€ ๐Ÿ“„ package.json              # Project dependencies and scripts
โ”œโ”€โ”€ ๐Ÿ“„ tsconfig.json            # TypeScript configuration
โ”œโ”€โ”€ ๐Ÿ“„ tsconfig.build.json      # TypeScript build configuration
โ”œโ”€โ”€ ๐Ÿ“„ .gitignore               # Git ignore patterns
โ”œโ”€โ”€ ๐Ÿ“„ LICENSE                  # MIT license file
โ””โ”€โ”€ ๐Ÿ“„ README.md               # This file

๐Ÿ“– Usage

๐Ÿ“ฅ Input Schema

The server accepts requests with the following structure:

interface Request {
  method: 'GET' | 'POST' | 'PUT' | 'DELETE';
  url: string;                    // Valid URL
  data?: Record<string, any>;     // Request body (for POST/PUT)
  headers?: Record<string, string>; // HTTP headers
}

๐Ÿ“ค Response Schema

All responses follow this structure:

interface Response {
  status: 'ok' | 'error';
  code: number;                   // HTTP status code
  data: any;                      // Response body (parsed JSON if possible)
  error?: string;                 // Error message (if status is 'error')
}

๐Ÿ’ก Examples

๐Ÿ“‹ GET Request
{
  "method": "GET",
  "url": "https://api.example.com/users/123",
  "headers": {
    "Authorization": "Bearer token123"
  }
}
โž• POST Request
{
  "method": "POST",
  "url": "https://api.example.com/users",
  "headers": {
    "Content-Type": "application/json"
  },
  "data": {
    "name": "John Doe",
    "email": "john@example.com"
  }
}
โœ… Success Response
{
  "status": "ok",
  "code": 200,
  "data": {
    "id": 123,
    "name": "John Doe",
    "email": "john@example.com"
  }
}
โŒ Error Response
{
  "status": "error",
  "code": 401,
  "data": {
    "message": "Unauthorized"
  },
  "error": "Authentication required (HTTP 401). The API endpoint requires authentication. Please provide an Authorization header (e.g., \"Authorization\": \"Bearer YOUR_TOKEN\" or \"Authorization\": \"Basic YOUR_CREDENTIALS\"). Check the API documentation for the correct authentication method."
}

๐Ÿšจ Intelligent Error Handling

The server provides helpful guidance for common HTTP errors:

StatusErrorGuidance
401๐Ÿ”’ UnauthorizedSuggests adding authentication headers with examples
403โ›” ForbiddenExplains permission issues and troubleshooting steps
429โฐ Rate LimitedRecommends waiting and implementing backoff strategies
400โŒ Bad RequestGuides on fixing request format and validation issues
404๐Ÿ” Not FoundHelps verify URLs and resource existence
5xx๐Ÿ› ๏ธ Server ErrorsAdvises on retry strategies and temporary issues

Each error response includes specific, actionable guidance to help resolve the issue quickly.


๐Ÿ’ป VS Code Integration

๐Ÿ”ง Setting Up MCP in VS Code

1๏ธโƒฃ Install an MCP Extension

Install one of these MCP extensions in VS Code:

๐Ÿ“ฆ automatalabs.copilot-mcp
๐Ÿ“ฆ buildwithlayer.mcp-integration-expert-eligr  
๐Ÿ“ฆ semanticworkbenchteam.mcp-server-vscode
2๏ธโƒฃ Configure MCP Settings

The .vscode/mcp.json file is already configured:

{
  "servers": {
    "curl": {
      "type": "stdio",
      "command": "node",
      "args": ["dist/index.js"]
    }
  }
}
3๏ธโƒฃ Build and Start
npm run build
npm start
4๏ธโƒฃ Use in VS Code

Open VS Code's command palette (Cmd+Shift+P) and look for MCP-related commands to interact with your server.

๐Ÿงช Testing with Dummy Endpoints

Here are some free JSON API endpoints you can use for testing:

๐Ÿท๏ธ JSONPlaceholder (Fake REST API)
  • ๐ŸŒ Base URL: https://jsonplaceholder.typicode.com
  • ๐Ÿ“‹ Features: Users, Posts, Comments, Albums, Photos, Todos
๐Ÿ”ฌ Example Requests to Test Your MCP Server
1๏ธโƒฃ GET Users
{
  "method": "GET",
  "url": "https://jsonplaceholder.typicode.com/users"
}
2๏ธโƒฃ GET Single User
{
  "method": "GET",
  "url": "https://jsonplaceholder.typicode.com/users/1"
}
3๏ธโƒฃ CREATE Post
{
  "method": "POST",
  "url": "https://jsonplaceholder.typicode.com/posts",
  "headers": {
    "Content-Type": "application/json"
  },
  "data": {
    "title": "My New Post",
    "body": "This is the content of my post",
    "userId": 1
  }
}
4๏ธโƒฃ UPDATE Post
{
  "method": "PUT",
  "url": "https://jsonplaceholder.typicode.com/posts/1",
  "headers": {
    "Content-Type": "application/json"
  },
  "data": {
    "id": 1,
    "title": "Updated Post Title",
    "body": "Updated post content",
    "userId": 1
  }
}
5๏ธโƒฃ DELETE Post
{
  "method": "DELETE",
  "url": "https://jsonplaceholder.typicode.com/posts/1"
}
๐ŸŒ Other Test APIs
APIDescriptionExample Endpoints
HTTPBinHTTP testing servicehttps://httpbin.org/get, https://httpbin.org/post
ReqResFake user APIhttps://reqres.in/api/users, https://reqres.in/api/users/2

๐Ÿ”„ VS Code Usage Workflow

graph TD
    A[๐Ÿš€ Start MCP Server] --> B[๐Ÿ“– Open VS Code]
    B --> C[โŒจ๏ธ Access MCP Commands]
    C --> D[๐Ÿ“จ Send HTTP Requests]
    D --> E[๐Ÿ‘€ View JSON Responses]
    
    A1[npm start] --> A
    C1[Cmd+Shift+P โ†’ MCP] --> C
  1. ๐Ÿš€ Start the MCP Server: Run npm start in your terminal
  2. ๐Ÿ“– Open VS Code: Open any file or workspace
  3. โŒจ๏ธ Access MCP Commands: Use Cmd+Shift+P โ†’ Search for "MCP"
  4. ๐Ÿ“จ Send Requests: Use the MCP interface to send HTTP requests through your server
  5. ๐Ÿ‘€ View Responses: See structured JSON responses in VS Code

๐Ÿงช Testing Commands

The repository includes a comprehensive test-requests.json file with sample requests for testing all HTTP operations. For detailed information about each test request, see .

๐Ÿ“‹ Test Coverage Includes:

  • JSONPlaceholder API: Users and Posts HTTP operations
  • HTTPBin API: HTTP testing with custom headers
  • ReqRes API: User API with pagination

You can use these test requests directly with your MCP client to verify the server functionality.


๐Ÿ”’ Security Considerations

Security FeatureDescription
โœ… Input ValidationAll inputs are validated using Zod schemas
๐Ÿ›ก๏ธ Command Injection PreventionInput sanitization prevents curl command injection attacks
โฐ Timeout ProtectionBuilt-in timeouts (30s max, 10s connect) prevent hanging requests
๐ŸŒ Network AccessThis server can make arbitrary HTTP requests - ensure proper network policies
๐Ÿ”‘ HeadersBe careful with sensitive headers like API keys
๐Ÿ“Š Rate LimitingThe server includes guidance for handling API rate limits appropriately

๐Ÿ”ง Troubleshooting

โš ๏ธ Common Issues

๐Ÿšซ "Cannot find module dist/index.js"

Solution:

  • Run npm run build to compile TypeScript to JavaScript
  • The dist/ directory will be created automatically during build
  • Note: The dist/ folder is not tracked in git as it contains compiled output
  • Check that tsconfig.json has "outDir": "./dist" and "rootDir": "./src"
๐Ÿ”ด TypeScript Compilation Errors

Solution: Ensure all dependencies are installed (npm install)

๐Ÿ“˜ MCP SDK Types

Solution: Custom type declarations are provided in src/@types/

๐Ÿ–ฅ๏ธ Curl Not Found

Solution: Ensure curl is installed on your system

๐ŸŒ Network Errors

Solution: Check target server accessibility and network policies

๐Ÿ”’ Authentication Errors (401/403)

Solutions:

  • Verify API keys and tokens are correct
  • Check if headers are properly formatted
  • Ensure your account has the required permissions
โฐ Rate Limiting (429)

Solutions:

  • Implement delays between requests
  • Use exponential backoff strategies
  • Check API documentation for rate limit policies
โฑ๏ธ Timeout Errors

Solutions:

  • Server requests timeout after 30 seconds for safety
  • Check if the target API is responding slowly
  • Consider if the endpoint requires different timeout settings

๐Ÿ’ก Development Tips

  • ๐Ÿ‘€ Use npm run dev for watch mode during development
  • ๐Ÿ” Check VS Code problems panel for TypeScript errors
  • ๐Ÿš€ Test with simple GET requests first
  • โœ… Validate JSON responses from target servers

๐Ÿค Contributing

We welcome contributions to improve the MCP HTTP Proxy server! Here's how you can contribute:

๐Ÿš€ Quick Start

  1. ๐Ÿด Fork the repository on GitHub: akhshyganesh/mcp-http-proxy
  2. ๐ŸŒฟ Create a feature branch: git checkout -b feature/your-feature-name
  3. โœจ Make your changes and ensure they follow the existing code style
  4. ๐Ÿงช Add tests if applicable
  5. ๐Ÿ’พ Commit your changes: git commit -am 'Add some feature'
  6. ๐Ÿ“ค Push to the branch: git push origin feature/your-feature-name
  7. ๐Ÿ”„ Submit a pull request through GitHub

๐Ÿ“‹ Development Guidelines

  • โœ… Follow TypeScript best practices
  • ๐Ÿ“ Use meaningful commit messages
  • ๐Ÿ“š Update documentation for new features
  • ๐Ÿ—๏ธ Ensure all builds pass before submitting PR

๐Ÿ“š References


๐Ÿงช Testing

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

Test Coverage

The test suite includes:

  • โœ… Server startup tests - Ensures the server starts without crashing
  • โœ… Executable validation - Verifies CLI binary has correct shebang
  • โœ… Module import tests - Confirms the module can be imported
  • โœ… Build verification - Validates TypeScript compilation

Continuous Integration

GitHub Actions automatically:

  • โœ… Runs tests on multiple Node.js versions (18, 20, 22)
  • โœ… Tests on multiple platforms (Ubuntu, Windows, macOS)
  • โœ… Performs security audits
  • โœ… Validates code quality with ESLint

๐Ÿ”’ Security

Security Features

  • โœ… Input Sanitization - All user inputs are validated and sanitized
  • โœ… Command Injection Protection - Safe curl command construction
  • โœ… Timeout Protection - Prevents hanging requests
  • โœ… Error Handling - Secure error messages without sensitive data
  • โœ… Dependency Scanning - Regular security audits of dependencies

Security Auditing

# Run security audit
npm audit

# Fix security issues
npm audit fix

# Check for high-severity vulnerabilities
npm audit --audit-level=high

Reporting Security Issues

If you discover a security issue, please:

  1. DO NOT open a public GitHub issue
  2. Email security concerns to: akhshy.balakannan@gmail.com
  3. Include details about the vulnerability
  4. Allow time for the issue to be addressed before public disclosure

๐Ÿค Contributing

Development Workflow

  1. Fork the repository
  2. Clone your fork locally
  3. Install dependencies: npm install
  4. Build the project: npm run build
  5. Run tests: npm test
  6. Make changes and add tests
  7. Lint code: npm run lint:fix
  8. Create a pull request

Code Quality Standards

  • โœ… All code must pass TypeScript compilation
  • โœ… All tests must pass
  • โœ… Code coverage should not decrease
  • โœ… ESLint rules must be followed
  • โœ… Security audit must pass

๐Ÿ“„ License

This project is licensed under the MIT License - see the file for details.


๐ŸŒŸ Made with โค๏ธ by Akhshy Ganesh

โญ Star this repo if you found it helpful!