Skip to content

Commit 3d47ab9

Browse files
feat(mcp): update README and test tools for MCP server integration
- Add MCP server documentation to README.md - Update mock database context in test_tools.py for MCP handlers
1 parent 1b25299 commit 3d47ab9

2 files changed

Lines changed: 45 additions & 9 deletions

File tree

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,48 @@ See [docs/reference/](docs/reference/) for details.
7777

7878
---
7979

80+
## MCP Server
81+
82+
pyplots provides an [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server for AI assistants to search plot specifications and fetch implementation code.
83+
84+
**Available Tools:**
85+
- `list_specs` - List all plot specifications
86+
- `search_specs_by_tags` - Search by plot type, domain, features, library
87+
- `get_spec_detail` - Get full specification with all implementations
88+
- `get_implementation` - Get code for a specific library
89+
- `list_libraries` - List supported plotting libraries
90+
- `get_tag_values` - Get available tag values by category
91+
92+
### Configuration
93+
94+
Add to your MCP client configuration (e.g., Claude Code `.mcp.json`):
95+
96+
**SSE Transport** (recommended, wider compatibility):
97+
```json
98+
{
99+
"mcpServers": {
100+
"pyplots": {
101+
"command": "npx",
102+
"args": ["-y", "mcp-remote", "https://api.pyplots.ai/sse/"]
103+
}
104+
}
105+
}
106+
```
107+
108+
**Streamable HTTP Transport** (modern, bidirectional):
109+
```json
110+
{
111+
"mcpServers": {
112+
"pyplots": {
113+
"command": "npx",
114+
"args": ["-y", "mcp-remote", "https://api.pyplots.ai/mcp/"]
115+
}
116+
}
117+
}
118+
```
119+
120+
---
121+
80122
## License Notes
81123

82124
Most plotting libraries are fully open source. Note these exceptions:

tests/unit/api/mcp/test_tools.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,12 @@
2929

3030
@pytest.fixture
3131
def mock_db_context():
32-
"""Mock database context manager."""
32+
"""Mock database session for MCP handlers."""
3333
mock_session = AsyncMock()
34-
35-
class MockContextManager:
36-
async def __aenter__(self):
37-
return mock_session
38-
39-
async def __aexit__(self, exc_type, exc_val, exc_tb):
40-
pass
34+
mock_session.close = AsyncMock()
4135

4236
with (
43-
patch("api.mcp.server.get_db_context", return_value=MockContextManager()),
37+
patch("api.mcp.server.get_mcp_db_session", AsyncMock(return_value=mock_session)),
4438
patch("api.mcp.server.is_db_configured", return_value=True),
4539
):
4640
yield mock_session

0 commit comments

Comments
 (0)