MCP-Server---Physics-Problem-Solver

rgjaci/MCP-Server---Physics-Problem-Solver

3.1

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:

  1. Predicts relevant formulas and concepts from its memory.
  2. Retrieves and applies them with a symbolic equation-solving engine (SymPy).
  3. 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 with Pint 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).

๐Ÿ› ๏ธ 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