mcp-server

varshneytarun/mcp-server

3.2

If you are the rightful owner of mcp-server 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.

A Model Context Protocol (MCP) server that facilitates API interactions using GET requests and path parameters.

Tools
5
Resources
0
Prompts
0

MCP API Server

A Model Context Protocol (MCP) server that provides tools to call multiple APIs with GET requests and path parameters.

Features

  • Support for multiple API endpoints
  • Path parameter substitution
  • Configurable API definitions
  • Error handling and validation
  • JSON response formatting

Installation

  1. Clone or create the project directory
  2. Install dependencies:
npm install

Configuration

The server comes pre-configured with several example APIs:

  • jsonplaceholder_user: Get user info from JSONPlaceholder
  • jsonplaceholder_post: Get post info from JSONPlaceholder
  • httpbin_uuid: Get UUID from httpbin
  • httpbin_status: Get specific HTTP status codes
  • httpbin_delay: Get response after delay

To add your own APIs, modify the API_CONFIGS array in server.js:

const API_CONFIGS = [
  {
    name: 'your_api_name',
    description: 'Description of your API',
    baseUrl: 'https://your-api.com',
    path: '/endpoint/{param}',
    parameters: [
      {
        name: 'param',
        type: 'string',
        description: 'Parameter description',
        required: true
      }
    ]
  }
];

Usage

Running the Server

npm start

The server runs on stdio transport and communicates via MCP protocol.

Available Tools

  1. jsonplaceholder_user

    • Get user by ID
    • Parameters: id (required)
    • Example: {"id": "1"}
  2. jsonplaceholder_post

    • Get post by ID
    • Parameters: id (required)
    • Example: {"id": "1"}
  3. httpbin_uuid

    • Generate UUID
    • No parameters required
  4. httpbin_status

    • Test HTTP status codes
    • Parameters: code (required)
    • Example: {"code": "200"}
  5. httpbin_delay

    • Test delayed responses
    • Parameters: seconds (required, 1-10)
    • Example: {"seconds": "3"}

Example Responses

{
  "status": 200,
  "statusText": "OK",
  "data": {
    "id": 1,
    "name": "Leanne Graham",
    "username": "Bret",
    "email": "Sincere@april.biz"
  },
  "headers": {
    "content-type": "application/json; charset=utf-8"
  }
}

Integration with MCP Clients

Method 1: Workspace Configuration (Recommended for sharing with team)

Create the configuration file:

In your VS Code workspace root, create a .vscode/mcp.json file

Add your server configuration: VS Code MCP Configuration (.vscode/mcp.json)

{
  "servers": {
    "api-mcp-server": {
      "type": "stdio",
      "command": "node",
      "args": ["${workspaceFolder}/src/server.js"]
    }
  }
}

Method 2: User Settings (Available across all workspaces)

Open VS Code Settings (Ctrl/Cmd + ,) Search for "mcp" Add to your settings.json:

{
  "mcp": {
    "servers": {
      "api-mcp-server": {
        "type": "stdio",
        "command": "node",
        "args": ["/full/path/to/your/server.js"]
      }
    }
  }
}

Method 3: Using VS Code Commands

  • Open Command Palette (Ctrl/Cmd + Shift + P)
  • Run: MCP: Add Server
  • Fill in the details:

Server name: api-mcp-server

Command: node

Args: path/to/your/server.js

  • Choose: Workspace Settings or User Settings

Prerequisites

Enable MCP support:

MCP support is available starting in VS Code release 1.99 Enable the chat.mcp.enabled setting (enabled by default)

Ensure your server is ready:

Your server.js file is executable Dependencies are installed (npm install) Server runs without errors when tested standalone

Adding New APIs

  1. Add a new configuration object to API_CONFIGS
  2. Define the API name, description, base URL, and path
  3. Specify parameters with types and requirements
  4. Restart the server

Error Handling

The server handles various error scenarios:

  • Missing required parameters
  • Network timeouts
  • HTTP error responses
  • Invalid API configurations

Requirements

  • Node.js 18+
  • @modelcontextprotocol/sdk
  • axios

License

MIT