Math Expression MCP Server

by eriktilio

LangChain + Gemini + MCP (Tool Server)

Este projeto demonstra como criar um chain com LangChain usando o modelo gemini-2.0-flash do Google e integrá-lo com ferramentas customizadas usando o MCP (Multi-Chain Protocol), via conexão stdio.

✨ Funcionalidade

A chain é capaz de:

  • Interpretar linguagem natural com o Gemini.
  • Usar ferramentas externas via MCP — neste exemplo, uma calculadora de expressões matemáticas.
  • Executar localmente um servidor de ferramentas que se conecta à chain automaticamente.

🔧 Requisitos

  • Python 3.10+
  • uv (ou pip tradicional)

📦 Instalação

Com uv (recomendado)
uv venv source .venv/bin/activate uv pip install -r requirements.txt
Ou com pip tradicional
python -m venv .venv source .venv/bin/activate pip install -r requirements.txt
Crie um arquivo .env:
GOOGLE_API_KEY=sua_chave_google_api

🚀 Execução

1. Execute o servidor de ferramentas (MCP)

Primeiro, execute o servidor de ferramentas. Este servidor vai processar as expressões matemáticas.

python server.py

2. Execute o cliente

Em seguida, execute o cliente, que se conecta ao servidor e faz as requisições, passando a pergunta para a chain e recebendo o resultado do cálculo.

python client.py

Como Funciona?

  • O chain usa o modelo Gemini-Pro do Google para interpretar a linguagem natural.
  • Uma LLMChain é criada usando o modelo e um PromptTemplate para extrair a expressão matemática de uma pergunta.
  • A expressão extraída é então passada para uma ferramenta de cálculo via o protocolo MCP.
  • O servidor MCP calcula a expressão matemática e retorna o resultado.
-
security - not tested
-
license - not tested
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

A tool server that processes mathematical expressions via Multi-Chain Protocol (MCP), allowing LLMs to solve math problems through tool integration.

  1. ✨ Funcionalidade
    1. 🔧 Requisitos
      1. 📦 Instalação
        1. Com uv (recomendado)
        2. Ou com pip tradicional
        3. Crie um arquivo .env:
      2. 🚀 Execução
        1. 1. Execute o servidor de ferramentas (MCP)
        2. 2. Execute o cliente
        3. Como Funciona?

      Related MCP Servers

      • -
        security
        A
        license
        -
        quality
        MCP server for toolhouse.ai. This does not rely on an external llm unlike the official server.
        Last updated -
        1
        Python
        MIT License
      • A
        security
        A
        license
        A
        quality
        A Model Context Protocol server that provides basic mathematical and statistical functions to LLMs, enabling them to perform accurate numerical calculations through a simple API.
        Last updated -
        13
        2
        TypeScript
        MIT License
      • A
        security
        A
        license
        A
        quality
        A Model Context Protocol server that enables LLMs to perform precise numerical calculations by evaluating mathematical expressions.
        Last updated -
        1
        48
        Python
        MIT License
        • Linux
        • Apple
      • A
        security
        A
        license
        A
        quality
        An MCP server that enables LLMs to perform blockchain operations on the Base network through natural language commands, including wallet management, balance checking, and transaction execution.
        Last updated -
        4
        4
        1
        TypeScript
        MIT License
        • Apple

      View all related MCP servers

      ID: c2t1088r9w