# 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_doi` | Resolve DOI to BibTeX | `doi` |
| `bib_pdf` | Download PDF + extract + BibTeX (full pipeline) | `doi` |
| `bib_extract` | Extract a local PDF to Markdown + figures | `pdf_path`, `output_dir` |

## How Auto-Discovery Works

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

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

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

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

## Using via MCP

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

```json
{
  "tool": "bib_search",
  "arguments": {
    "query": "formal verification",
    "limit": 5
  }
}
```

The `limit` parameter follows the same validation rules as the CLI:

- Must be ≥ 1
- Clamped to 100 if larger

## Configuration

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