Cover image
Try Now
2025-03-22

该项目演示了如何创建和使用模型上下文协议(MCP)服务器,该协议可以为Claude和其他支持MCP标准的AI助手提供自定义工具和资源。服务器包括: - 简单的数学操作(加法) - 动态问候资源 - 使用crawl4ai库的Web爬行功能

3 years

Works with Finder

1

Github Watches

1

Github Forks

3

Github Stars

MCP Server POC

A proof-of-concept implementation of a Model Context Protocol (MCP) server for enhancing AI assistant capabilities with custom tools and resources.

Overview

This project demonstrates how to create and use a Model Context Protocol (MCP) server that can provide custom tools and resources to AI assistants like Claude and others that support the MCP standard. The server includes:

  • Documentation search tool for LangChain, LlamaIndex, and OpenAI
  • Web crawling capability
  • Integration with Google Search API

Requirements

  • Python 3.11
  • Required packages listed in requirements.txt

Installation and Setup

  1. Clone this repository:
git clone https://github.com/yourusername/mcp-server-poc.git
cd mcp-server-poc
  1. Create and activate a virtual environment:
# Create a Python 3.11 virtual environment
python -m venv venv

# Activate on Windows
 .\venv\Scripts\Activate.ps1

# Activate on macOS/Linux
source venv/bin/activate
  1. Install the required packages:
pip install -r requirements.txt
  1. Set up environment variables:

    Create a .env file in the root directory with the following:

SERPER_API_KEY=your_serper_api_key_here

Running the Application

To run the MCP server:

python main.py

The server will start and wait for connections using the stdio transport method.

Integrating with Cursor

To use this MCP server with Cursor IDE:

  1. Create or edit the file ~/.cursor/mcp.json (on Windows: C:\Users\<username>\.cursor\mcp.json) with the following content:
{
    "mcpServers": {
        "mcp-server": {
            "command": "python", 
            "args": [
                "ABSOLUTE/PATH/TO/main.py"
            ]
        }
    }
}
  1. Replace the path with the absolute path to your main.py file.

    • On Windows, use double backslashes: C:\\Users\\username\\path\\to\\main.py
    • On macOS/Linux, use regular slashes: /Users/username/path/to/main.py
  2. Restart Cursor completely (including ending any background processes) to load the MCP server.

Features

Tools

  • get_docs(query, library): Searches the documentation for the specified library (langchain, llama-index, or openai) and returns relevant information

Technical Details

Windows Binary Mode Fix

This server includes a specific fix for Windows to ensure proper operation with stdio transport:

# Set binary mode for stdin/stdout on Windows
if os.name == 'nt':
    import msvcrt
    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
    msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)

This fix is necessary because Windows distinguishes between text and binary modes for file handling, which can cause issues with the stdio transport mechanism used by MCP.

Troubleshooting

If you encounter issues with the MCP server:

Windows-Specific Issues

  • "Failed to create client" or "Client closed" errors:
    • Make sure to use the binary mode fix included in the server
    • Use the absolute path with double backslashes in the mcp.json configuration
    • Try running the MCP server directly to see if it produces any error output
    • Completely exit Cursor (including terminating any background processes via Task Manager) before restarting

General Issues

  • Verify that all required packages are installed (pip list to check)
  • Check that the absolute path in the configuration file is correct
  • Make sure the MCP server is running with the proper version of Python (3.11)
  • Verify that your .env file contains the required API key
  • Try reinstalling the MCP package: pip uninstall mcp && pip install mcp

License

MIT License

Acknowledgements

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Yasir Eryilmaz
  • AI scriptwriting assistant for short, engaging video content.

  • INFOLAB OPERATIONS 2
  • A medical specialist offering assistance grounded in clinical guidelines. Disclaimer: This is intended for research and is NOT safe for clinical use!

  • Daren White
  • A supportive coach for mastering all Spanish tenses.

  • J. DE HARO OLLE
  • Especialista en juegos de palabras en varios idiomas.

  • albert tan
  • Japanese education, creating tailored learning experiences.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • huahuayu
  • 统一的API网关,用于将多个Etherscan样区块链Explorer API与对AI助手的模型上下文协议(MCP)支持。

  • deemkeen
  • 用电源组合控制您的MBOT2:MQTT+MCP+LLM

  • zhaoyunxing92
  • MCP(消息连接器协议)服务

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

    Reviews

    5 (1)
    Avatar
    user_Ndfcx8Yr
    2025-04-16

    I've been using mcp-server-poc for a while and I must say it significantly simplified my server management tasks. The setup was straightforward, and the documentation by TarcisioPhilips is thorough and easy to follow. Highly recommended for anyone looking to streamline their server operations! Check it out on GitHub: https://github.com/TarcisioPhilips/mcp-server-poc