A physics-aware reasoning server that learns from books, stores equations as memory, and solves problems by predicting and applying the right formulas—like an LLM, but with logic.
The MCP (Model Context Protocol) server is an intelligent system designed to solve physics problems by building a structured memory of physics equations, definitions, and concepts. It learns from books—PDFs or text—using the Google Gemini language model to extract, deduplicate, and interconnect key knowledge.
When given a physics question, the MCP server:
- Predicts relevant formulas and concepts from its memory.
- Retrieves and applies them with a symbolic equation-solving engine (SymPy).
- Produces a precise, explainable solution via MCP.
Unlike traditional LLMs that generate text token by token, this MCP server combines:
- LLM-powered semantic understanding (Google Gemini),
- A structured knowledge base (initially in-memory, potentially vector-based retrieval later), and
- Logic-driven symbolic math (SymPy).
- 📚 Learn from Books: Ingest textbooks (PDF/text) and extract meaningful formulas, definitions, and concepts.
- 🧠 Knowledge Base: Structured, queryable store of learned physics knowledge.
- 🔍 LLM-Powered Analysis: Use Google Gemini to interpret input problems and extract new knowledge.
- 🧮 Symbolic Equation Solving: Use
SymPyfor precise problem solving (unit handling withPintcan be integrated). - 🤖 MCP Interface: Expose capabilities as MCP tools and resources.
- 🗣️ Explainable Solutions: Provide step-by-step reasoning for solved problems.
- (Future) Embedding-Based Retrieval: Match new problems to known equations with vector search.
- (Future) Human-in-the-loop Editing: UI to review and edit extracted knowledge.
MCP Server - Physics Problem Solver/ │ ├── .venv/ # Virtual environment (typically in .gitignore) ├── server.py # Main MCP server logic, tool & resource definitions ├── sample_physics.txt # Example input file for ingestion ├── README.md # This file ├── .env # Environment variables (e.g., GEMINI_API_KEY) ├── requirements.txt # Python dependencies (to be created/updated) └── .instructions.md # Copilot project instructions (if used)
If you haven't already, create and activate a Python virtual environment:
# Navigate to your project directory
# cd "MCP Server - Physics Problem Solver"
python -m venv .venv
# On Windows
.venv\Scripts\activate
# On macOS/Linux
# source .venv/bin/activateCreate a requirements.txt file with the following content:
python-dotenv
google-generativeai
fastmcp
sympy
# Add other dependencies like PyPDF2 if you implement PDF parsingThen install them:
pip install -r requirements.txtCreate a .env file in the project root and add your Google Gemini API key:
GEMINI_API_KEY="your-gemini-api-key-here"Execute the server.py script:
python server.pyThe server will start and listen for MCP messages via standard input/output (stdio). You can interact with it using an MCP client like the MCP Inspector.
Tool: ingest_document
- Params:
{ "document_content": "Newton's second law states that Force = mass * acceleration. F=m*a.", "source_identifier": "Newton's Second Law Note" } - Server will:
- Use Gemini to parse the text.
- Extract the equation
F=m*aand the concept of "Newton's second law". - Store them in its in-memory knowledge base.
Tool: solve_physics_problem
- Params:
{ "question": "An object of mass 2 kg accelerates at 3 m/s². What is the force?" } - Server will:
- Use Gemini to analyze the question and identify relevant concepts/equations (e.g.,
F=m*a). - (Conceptually) Use SymPy to substitute values and solve.
- Return a structured response including the identified concepts, equations, steps, and the final answer (e.g.,
F = 6 N).
- Use Gemini to analyze the question and identify relevant concepts/equations (e.g.,
- Basic question parsing and LLM-driven analysis.
- Initial document ingestion (text-based).
- Robust PDF textbook ingestion.
- Enhanced symbolic solving with SymPy for a wider range of problems.
- Embedding-based retrieval for more scalable knowledge lookup.
- Development of a concept dependency graph.
- Unit and integration tests for all components.
- (Optional) Human-in-the-loop UI for knowledge base editing.
- (Future) Multilingual physics understanding.
MIT License
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
- Created by Reison Gjaci
- Powered by Google Gemini, SymPy, FastMCP, and Python