MCP cover image

如何设置MCP服务器和MCP客户端。

1

Github Watches

0

Github Forks

0

Github Stars

MCP Starter Project

What is MCP?

The Model Context Protocol (MCP) is a standard for building AI applications that can interact with external tools and APIs. It consists of two main components:

  1. MCP Server: A Python service that defines and exposes tools/functions that can be called by AI models
  2. MCP Client: A TypeScript/JavaScript client that connects to the MCP server and manages interactions between AI models and tools

Project Structure

mcp_starter/
├── mcp-server/           # Python MCP server implementation
│   ├── main.py          # Server with documentation search tool
│   └── pyproject.toml   # Python dependencies
└── mcp-clients/         # TypeScript MCP client implementation
    ├── index.ts         # Express server with HuggingFace integration
    └── package.json     # Node.js dependencies

Getting Started

Prerequisites

Setting Up the Server

  1. Create a Python virtual environment and activate it:
cd mcp-server
python -m venv .venv
# On Windows
.venv\Scripts\activate
  1. Install dependencies:
pip install -e .
  1. Create a .env file in the mcp-server directory:
SERPER_API_KEY=your_serper_api_key_here

Setting Up the Client

  1. Install Node.js dependencies:
cd mcp-clients
npm install
  1. Create a .env file in the mcp-clients directory:
HUGGINGFACE_API_KEY=your_huggingface_api_key_here
  1. Build the TypeScript code:
npm run build

Running the Application

  1. Start the MCP server:
cd mcp-server
python main.py
  1. In a new terminal, start the client server:
cd mcp-clients
node build/index.js ../mcp-server/main.py

Using the API

The client exposes two endpoints:

  • Health Check: GET http://localhost:3000/health
  • Chat: POST http://localhost:3000/chat

Example chat request:

{
  "query": "Search the langchain docs for RAG",
  "sessionId": "user123"
}

Features

  • Documentation Search Tool: Search documentation for popular AI libraries:

    • LangChain
    • LlamaIndex
    • OpenAI
  • Conversation Management: Maintains chat history per session

  • Tool Integration: Seamlessly integrates AI model responses with tool calls

  • Error Handling: Robust error handling for API calls and tool execution

How It Works

  1. The MCP server defines tools that can be called by AI models
  2. The client connects to the MCP server and retrieves available tools
  3. When a user sends a query:
    • The client formats the conversation history
    • Sends it to the Hugging Face model
    • Extracts and executes tool calls from the model's response
    • Returns the final response including tool results

Environment Variables

Server

  • SERPER_API_KEY: API key for Google Search functionality

Client

  • HUGGINGFACE_API_KEY: API key for accessing Hugging Face models

License

MIT License

相关推荐

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

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

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

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

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

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

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • Lists Tailwind CSS classes in monospaced font

  • https://appia.in
  • Siri Shortcut Finder – your go-to place for discovering amazing Siri Shortcuts with ease

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

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

  • modelcontextprotocol
  • 模型上下文协议服务器

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

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

    Reviews

    4 (1)
    Avatar
    user_0vwhohnW
    2025-04-17

    As a loyal user of mcp_starter, I highly recommend this fantastic tool! It's incredibly easy to set up and has significantly improved my development workflows. Kudos to sharmatriloknath for creating such a valuable resource. For anyone looking to kickstart their projects efficiently, make sure to check it out at https://github.com/sharmatriloknath/mcp_starter!