Skip to content

[BUG] Can't annotate markdown file #66

@donatojb

Description

@donatojb

Describe the bug
The endpoint for annotations crashes when sending a markdown file.

To Reproduce

from axiomatic_mcp.servers.annotations.server import annotate_file_main
md_path = Path('tests/test6/test6_annotations.md')
response = await annotate_file_main(md_path, query='Test')

raises an error

---------------------------------------------------------------------------
HTTPStatusError                           Traceback (most recent call last)
File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/axiomatic_mcp/shared/api_client.py:28, in AxiomaticAPIClient._handle_raise_for_status(self, response)
     27 try:
---> 28     response.raise_for_status()
     29 except httpx.HTTPStatusError as e:

File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/httpx/_models.py:829, in Response.raise_for_status(self)
    828 message = message.format(self, error_type=error_type)
--> 829 raise HTTPStatusError(message, request=request, response=self)

HTTPStatusError: Server error '500 Internal Server Error' for url 'https://api.axiomatic-ai.com/annotations/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500

The above exception was the direct cause of the following exception:

HTTPStatusError                           Traceback (most recent call last)
File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/axiomatic_mcp/servers/annotations/server.py:150, in annotate_file_main(file_path, query)
    148 data = {"query": query}
--> 150 response = await asyncio.to_thread(
    151     AxiomaticAPIClient().post,
    152     "/annotations/",
    153     files=files,
    154     data=data,
    155 )
    157 annotations_response = AnnotationsResponse.model_validate(response)

File /opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/threads.py:25, in to_thread(func, *args, **kwargs)
     24 func_call = functools.partial(ctx.run, func, *args, **kwargs)
---> 25 return await loop.run_in_executor(None, func_call)

File /opt/homebrew/Cellar/python@3.13/3.13.7/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/thread.py:59, in _WorkItem.run(self)
     58 try:
---> 59     result = self.fn(*self.args, **self.kwargs)
     60 except BaseException as exc:

File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/axiomatic_mcp/shared/api_client.py:59, in AxiomaticAPIClient.post(self, endpoint, data, files, params)
     57     response = self.client.post(endpoint, json=data, params=params)
---> 59 self._handle_raise_for_status(response)
     60 return response.json()

File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/axiomatic_mcp/shared/api_client.py:32, in AxiomaticAPIClient._handle_raise_for_status(self, response)
     31     error_body = response.text
---> 32     raise httpx.HTTPStatusError(f"{e!s} - Response: {error_body}", request=response.request, response=response) from e
     33 except Exception:

HTTPStatusError: Server error '500 Internal Server Error' for url 'https://api.axiomatic-ai.com/annotations/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 - Response: {"detail":"Annotation failed: Error annotating source: Only images and PDFs are supported for binary content"}

The above exception was the direct cause of the following exception:

ToolError                                 Traceback (most recent call last)
Cell In[26], line 3
      1 from axiomatic_mcp.servers.annotations.server import annotate_file_main
      2 md_path = Path('tests/test6/test6_annotations.md')
----> 3 response = await annotate_file_main(md_path, query='Test')

File ~/Donato/Code/AutoVJ/.venv/lib/python3.13/site-packages/axiomatic_mcp/servers/annotations/server.py:163, in annotate_file_main(file_path, query)
    158     annotations_text = (
    159         format_annotations(annotations_response.annotations) if annotations_response.annotations else "No annotations found for the given query."
    160     )
    162 except Exception as e:
--> 163     raise ToolError(f"Failed to annotate file: {e!s}") from e
    165 try:
    166     with (file_path.parent / f"{file_path.stem}_annotations.md").open("w", encoding="utf-8") as f:

ToolError: Failed to annotate file: Server error '500 Internal Server Error' for url 'https://api.axiomatic-ai.com/annotations/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 - Response: {"detail":"Annotation failed: Error annotating source: Only images and PDFs are supported for binary content"}

Expected behavior
The endpoint should return the annotations for the pdf.

Environment (please complete the following information):

  • OS: macOS
  • Python version: 3.13.7
  • Package version: 0.1.15
  • MCP client: VSCode

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions