Sponsored by Deepsite.site

MCP Simple Server

Created By
Omerisra68 months ago
A simple server implementing the Model Context Protocol for document search
Content

MCP Simple Server

A simple server implementing the Model Context Protocol (MCP).

Setup

  1. Install dependencies:
npm install
  1. Start the server:
npm start

The server will run on http://localhost:3001 by default.

Using the Stdio Server

This project includes a stdio-based implementation of the MCP server that communicates via standard input/output instead of HTTP/SSE.

Running the Stdio Server

npm run stdio

The stdio server accepts JSON-RPC messages via stdin and responds via stdout. All logs are sent to stderr to avoid interfering with the JSON-RPC messages.

Using the MCP Inspector

If you want to use the MCP Inspector with the stdio server, we've created a bridge that connects the HTTP-based inspector to our stdio server:

npm run bridge

This will:

  1. Start the stdio server as a child process
  2. Create an HTTP server on port 3001
  3. Forward JSON-RPC requests from HTTP to the stdio server
  4. Return responses back to the HTTP clients

You can then connect the MCP Inspector to http://localhost:3001 and it will work with the stdio server.

Using the Interactive CLI

An interactive command-line interface is provided for easy interaction with the stdio server:

npm run cli

This will start an interactive shell where you can enter search queries:

MCP CLI - Interactive interface to the MCP server
Type "exit" or press Ctrl+C to quit
Examples:
  documents/javascript - Search for documents with keyword "javascript"
  help - Show this help message
--------------------------------------------------
> 

You can enter simple keywords or full document URIs to search.

Using the Sample Client

A sample client is included to demonstrate how to communicate with the stdio server programmatically:

npm run client <query>

For example:

npm run client javascript

This will:

  1. Start the stdio server as a child process
  2. Send a query for documents matching "javascript"
  3. Display the results and exit

Communicating Directly with the Stdio Server

You can also communicate directly with the stdio server by piping JSON-RPC messages:

echo '{"jsonrpc":"2.0","id":"1","method":"mcp.uri","params":{"uri":"documents/sample"}}' | node stdio-server.mjs

Custom Domain Setup

You can access the server via a custom domain by mapping it in your hosts file.

Automatic Setup

Run the included setup script with sudo permissions:

sudo ./hosts-setup.sh

This will add mcp.local to your hosts file pointing to 127.0.0.1 and flush your DNS cache.

Manual Setup

  1. Edit your hosts file:

    • On macOS/Linux: /etc/hosts
    • On Windows: C:\Windows\System32\drivers\etc\hosts
  2. Add the following line:

127.0.0.1 mcp.local
  1. Flush your DNS cache:

    • On macOS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
    • On Windows: ipconfig /flushdns
    • On Linux: Depends on your distribution
  2. Access the server at http://mcp.local:3001

Environment Variables

You can customize the server by setting the following environment variables:

  • PORT: The port to run the server on (default: 3001)
  • DOMAIN_NAME: The custom domain name (default: mcp.local)
  • SERVER_IP: The IP address to bind to (default: 127.0.0.1)

Example:

PORT=8080 DOMAIN_NAME=myapi.local npm start
Recommend Servers
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Serper MCP ServerA Serper MCP Server
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
Tavily Mcp
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
ChatWiseThe second fastest AI chatbot™
Playwright McpPlaywright MCP server
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
TimeA Model Context Protocol server that provides time and timezone conversion capabilities. This server enables LLMs to get current time information and perform timezone conversions using IANA timezone names, with automatic system timezone detection.
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
Context7Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
CursorThe AI Code Editor
DeepChatYour AI Partner on Desktop