# MCP Integration

`axm-bib` tools are automatically discovered by `axm-mcp` and exposed as MCP tools for AI agents.

## Available Tools

| MCP Tool | Description | Parameters |
|---|---|---|
| `bib_search` | Search papers by keywords | `query`, `limit` |
| `bib_resolve` | Resolve one or more identifiers to BibTeX | `ref` (single) or `refs` (multi-ref merge) |
| `bib_resolve_batch` | Batch-resolve N papers × M identifiers each | `papers: list[list[str]]` |
| `bib_pdf` | Download PDF + extract + BibTeX (full pipeline) | `ref` (any identifier) |
| `bib_graph` | Citation graph traversal | `paper_id`, `direction`, `limit` |
| `bib_extract` | Extract a local PDF to Markdown + figures | `pdf_path`, `output_dir` |

!!! warning "ID-only resolution"
    `bib_resolve` and `bib_resolve_batch` **only accept identifiers** (DOI, arXiv, HAL,
    DBLP, OpenReview). Titles are rejected — use `bib_search` to discover papers by title.

## How Auto-Discovery Works

`axm-mcp` scans installed packages for `axm.tools` entry points. Each tool class that satisfies the `AXMTool` protocol is automatically registered as an MCP tool.

```python
# axm_bib/tools/bib_search.py
class BibSearchTool:
    """Search papers by title/keywords, return structured metadata + DOI."""

    @property
    def name(self) -> str:
        return "bib_search"

    def execute(self, *, query: str = "", limit: int = 10, **kwargs: Any) -> ToolResult:
        pipeline = BibPipeline()
        papers = pipeline.search(query, limit=limit)
        ...
```

## Using via MCP

Once `axm-mcp` is running, AI agents can call tools directly:

```python
# Search for papers
bib_search(query="formal verification", limit=5)

# Resolve a single identifier
bib_resolve(ref="10.1145/363235.363259")

# Merge multiple identifiers for the same paper
bib_resolve(refs=["10.1234/test", "arXiv:2503.18813"])

# Batch: resolve multiple papers, each with N identifiers
bib_resolve_batch(papers=[
    ["10.1/a", "arXiv:2503.1"],   # paper 1: merge 2 IDs
    ["10.1/b"],                    # paper 2: single ID
])
```

## Configuration

No additional configuration is needed. As long as `axm-bib` is installed in the same environment as `axm-mcp`, tools are discovered automatically.
