Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions axiomatic_mcp/servers/equations/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ async def _get_document_content(document: Path | str) -> str:
@mcp.tool(
name="find_functional_form",
description=(
"Derive an expression of your interest given the information from the source documents "
"Compose an expression of your interest given the information from the source documents "
"and equations residing there. Provide description of the expression you want to compose."
),
tags=["equations", "compose", "derive", "find", "function-finder"],
Expand All @@ -74,24 +74,31 @@ async def find_expression(
input_body = {"markdown": doc_content, "task": task}
response = AxiomaticAPIClient().post("/equations/derive/markdown", data=input_body)

code = response.get("composer_code", "")

if not code:
raise ToolError("No composer_code returned from service")

code = response.get("composer_code", "")

if isinstance(document, Path) or (isinstance(document, str) and Path(document).exists()):
doc_path = Path(document)
file_path = doc_path.parent / f"{doc_path.stem}_code.py"
else:
file_path = Path.cwd() / "expression_code.py"

with Path.open(file_path, "w", encoding="utf-8") as f:
f.write(response.get("code", ""))
f.write(code)

return ToolResult(
content=[
TextContent(type="text", text=f"Explanation: {response.get('explanation', '')}"),
TextContent(type="text", text=f"Code: {response.get('code', '')}"),
TextContent(type="text", text=f"Comments: {response.get('comments', '')}"),
TextContent(type="text", text=f"Code: {response.get('composer_code', '')}"),
]
)

except Exception as e:
raise ToolError(f"Failed to derive the equation in the document: {e!s}") from e
raise ToolError(f"Failed to analyze document: {e!s}") from e


@mcp.tool(
Expand All @@ -115,19 +122,10 @@ async def check_equation(
# Note: Using the same endpoint for now, but this could be changed to a dedicated checking endpoint
response = AxiomaticAPIClient().post("/equations/check/markdown", data=input_body)

if isinstance(document, Path) or (isinstance(document, str) and Path(document).exists()):
doc_path = Path(document)
file_path = doc_path.parent / f"{doc_path.stem}_code.py"
else:
file_path = Path.cwd() / "expression_code.py"

with Path.open(file_path, "w", encoding="utf-8") as f:
f.write(response.get("code", ""))

return ToolResult(
content=[
TextContent(type="text", text=f"Explanation: {response.get('explanation', '')}"),
TextContent(type="text", text=f"Code: {response.get('code', '')}"),
TextContent(type="text", text=f"Comments: {response.get('comments', '')}"),
TextContent(type="text", text=f"Code: {response.get('composer_code', '')}"),
]
)

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "axiomatic-mcp"
version = "0.1.13"
version = "0.1.14"
description = "Modular MCP servers for Axiomatic_AI"
authors = [{ name = "Axiomatic Team", email = "developers@axiomatic-ai.com" }]
readme = "README.md"
Expand Down