Skip to content

Fix critical server startup and performance issues #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions pymupdf4llm_mcp/app.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import os
from pathlib import Path
from typing import Annotated, Any

import pymupdf4llm
from mcp.server.fastmcp import FastMCP
from pydantic import Field

mcp = FastMCP("pymupdf4llm-mcp")
# Fix: Set environment variable and explicit log level to prevent validation error
os.environ.setdefault('LOG_LEVEL', 'INFO')
mcp = FastMCP("pymupdf4llm-mcp", log_level='INFO')


@mcp.tool(
Expand Down Expand Up @@ -47,7 +50,7 @@ def convert_pdf_to_markdown(
if save_path:
save_path: Path = Path(save_path).expanduser().resolve()
save_path.parent.mkdir(parents=True, exist_ok=True)
content = pymupdf4llm.to_markdown(file_path, write_images=True, image_path=image_path.as_posix())
# Fix: Remove duplicate PDF processing - content is already generated above
with open(save_path, "w", encoding="utf-8") as f:
f.write(content)
return {
Expand All @@ -73,4 +76,4 @@ def convert_pdf_to_markdown(
return {
"error": f"Failed to convert PDF to markdown: {e!s}",
"success": False,
}
}
Loading