MCP服务器工具

一个基于Python的MCP服务器工具,用于本地构建和测试模型上下文协议(MCP)服务器,支持计算器功能作为MCP工具。

  • by ItsMistahJi
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 itsmistahji/simple_python_mcp_calculator

使用说明

Simple_Python_MCP_计算器

这是一个简单的python MCP计算器。创建、实施和运行MCP服务器很简单。这也有助于在本地创建MCP服务器。

# MCP Server Example

A simple example of building and testing a Model Context Protocol (MCP) server locally using Python and MCP Inspector. This project demonstrates how to expose calculator functions as MCP tools and test them interactively.

---

## 🚀 Features

- Implements a basic MCP server in Python
- Exposes calculator operations as MCP tools
- Includes a sample resource endpoint
- Easily testable locally with MCP Inspector

---

## 🛠️ Prerequisites

- Python 3.8 or higher
- [MCP Python SDK]
- [MCP CLI]
- (Recommended) Virtual Environment

---

## 📦 Installation

1. Clone the repository

git clone https://github.com/ItsMistahJi/Simple_Python_MCP_calculator.git


cd Simple_Python_MCP_calculator



2. Create and activate a virtual environment


python3 -m venv venv
source venv/bin/activate



3. Install dependencies


pip install mcp
pip install mcp[cli]



## ▶️ Running & Testing the Server

1. Start the MCP server using the MCP CLI:

mcp dev calculator.py



2. Open the MCP Inspector link provided in your terminal.

3. Test your tools and resources interactively in the Inspector UI.

---

## To add it in your MCP client. Use the below JSON in the MCP client settings.

            "Calculator": {
                "type": "stdio",
                "command": "/path/to/your/venv/bin/python",
                "args": [
                    "/path/to/your/calculator.py"
                ]
            }


*Happy building with MCP!*