数学计算服务器

一个基于模型上下文协议(MCP)的服务器,提供通过streamable-http传输协议访问的数学工具(加、减、乘、除)。

  • by upxill
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 upxill/langchain-mcp-server

使用说明

MCP Server

A Model Context Protocol (MCP) server that provides mathematical tools (add, subtract, multiply, divide) accessible via the streamable-http transport.

Overview

This MCP server exposes four mathematical operations as tools:

  • add: Add two integers
  • sub: Subtract two integers
  • mul: Multiply two integers
  • div: Divide two integers

The server runs on http://localhost:8000/mcp using the streamable-http transport protocol.

Prerequisites

  • Python 3.13+

Installation

uv sync

Running

uv run main.py

The server will start on http://localhost:8000/mcp and wait for MCP client connections.

Architecture

  • FastMCP: Simplified MCP server framework
  • streamable-http: Transport protocol for server-client communication
  • Tool Definitions: Four simple math operations exposed as MCP tools

API Endpoints

The server provides a streamable-http endpoint at:

http://localhost:8000/mcp

Tools

add(a: int, b: int) -> int

Returns the sum of two integers.

sub(a: int, b: int) -> int

Returns the difference of two integers (a - b).

mul(a: int, b: int) -> int

Returns the product of two integers.

div(a: int, b: int) -> float

Returns the quotient of two integers (a / b).

Dependencies

  • mcp: Model Context Protocol library
  • fastmcp: Simplified MCP server framework