| from fastmcp import FastMCP |
| |
| import logging |
| import os |
|
|
| |
| mcp = FastMCP("Math-Education-Server") |
|
|
| |
| |
| CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| MARKDOWN_FILE = os.path.join(CURRENT_DIR, "resource", "jemh114-min (1).md") |
|
|
| def get_local_resource(): |
| if os.path.exists(MARKDOWN_FILE): |
| with open(MARKDOWN_FILE, "r", encoding="utf-8") as f: |
| return f.read() |
| return "Resource file not found." |
|
|
| @mcp.tool() |
| async def generate_chapter_summary(chapter_name: str) -> str: |
| """Provides source material and instructions for a math summary.""" |
| raw_data = get_local_resource() |
| return f""" |
| <source_material> |
| {raw_data[:4000]} |
| </source_material> |
| SYSTEM_INSTRUCTION: You are a Mathematics Expert. |
| 1. Summarize in 3 bullets. |
| 2. List formulas like $x = \\frac{{-b \\pm \\sqrt{{b^2-4ac}}}}{{2a}}$. |
| """ |
|
|
| @mcp.tool() |
| async def generate_quiz(chapter_name: str, difficulty: str = "medium") -> str: |
| raw_data = get_local_resource() |
| return f"Material: {raw_data[:2000]}\nDifficulty: {difficulty}\nCreate a 3-question quiz." |
|
|
| if __name__ == "__main__": |
| |
| |
| mcp.run( |
| transport="http", |
| port=7860, |
| host="0.0.0.0" |
| ) |