rgjaci/MCP-Server---Physics-Problem-Solver
If you are the rightful owner of MCP-Server---Physics-Problem-Solver and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The MCP Server is a physics-aware reasoning system that learns from books, stores equations as memory, and solves problems by predicting and applying the right formulas.
๐ง MCP Server โ Model Context Protocol for Physics
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.
๐ Overview
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).
๐ Features
- ๐ 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
SymPy
for precise problem solving (unit handling withPint
can 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.
๐๏ธ Project Structure
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)
โ๏ธ Getting Started
1. Setup Environment
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/activate
2. Install Dependencies
Create a requirements.txt
file with the following content:
python-dotenv
google-generativeai
fastmcp
sympy
# Add other dependencies like PyPDF2 if you implement PDF parsing
Then install them:
pip install -r requirements.txt
3. Configure API Key
Create a .env
file in the project root and add your Google Gemini API key:
GEMINI_API_KEY="your-gemini-api-key-here"
4. Run the MCP Server
Execute the server.py
script:
python server.py
The 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.
๐งช Example Interaction
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*a
and 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.,
๐ ๏ธ Roadmap
- 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.
๐ License
MIT License
๐ค Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
โจ Credits
- Created by Reison Gjaci
- Powered by Google Gemini, SymPy, FastMCP, and Python