-
Notifications
You must be signed in to change notification settings - Fork 5
feat(mcp): add MCP server module with auto-discovery #197
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
feat(mcp): add MCP server module with auto-discovery #197
Conversation
Implements Issue #166 - MCP server with tool auto-discovery: - discover_tools(): Returns deep copy of registered tools from decorator registry - generate_tool_schema(): Creates JSON schema from function signature/type hints - register_tools(): Registers all discovered tools with FastMCP server - get_server(): Returns singleton FastMCP instance - main(): Entry point for pleiades-mcp command Key features: - Python 3.10+ union syntax support (int | str, int | None) - Handles Union, Optional, list, dict, Any, nested types - O(n) performance documented for schema generation - Graceful error handling with specific exceptions - Unified loguru_logger usage throughout Test coverage: - 30 tests passing (13 skipped when FastMCP not installed) - Edge cases: forward refs, closures, async, generators, unicode - Security: SQL injection patterns, long strings, special characters Closes #166 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements MCP server module with auto-discovery functionality for Issue #166. The implementation adds core functions to discover, register, and expose PLEIADES tools via the Model Context Protocol (MCP), enabling AI-assisted neutron resonance analysis.
Key Changes:
- Auto-discovery system that reads tools from decorator registry
- JSON schema generation from Python type hints with support for modern Python 3.10+ union syntax
- Tool registration with FastMCP server
- Comprehensive test suite with 30 tests covering edge cases and error handling
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/unit/pleiades/mcp/test_server.py | Complete test suite covering tool discovery, registration, schema generation, server integration, error handling, and edge cases including Python 3.10+ union syntax |
| src/pleiades/mcp/server.py | Core implementation with discover_tools(), generate_tool_schema(), register_tools(), get_server(), and main() functions, plus type conversion utilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add NoneType constant at module level for efficient type comparisons - Use logger = loguru_logger.bind(name=__name__) pattern (codebase convention) - Replace all loguru_logger calls with bound logger - Use importlib.util.find_spec for cleaner fastmcp detection in tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Implements Issue #166 - MCP server module with tool auto-discovery:
discover_tools(): Returns deep copy of registered tools from decorator registrygenerate_tool_schema(): Creates JSON schema from function signature/type hintsregister_tools(): Registers all discovered tools with FastMCP serverget_server(): Returns singleton FastMCP instancemain(): Entry point forpleiades-mcpcommandKey Features
int | str,int | None)Union,Optional,list,dict,Any, nested typesloguru_loggerusage throughoutTest Coverage
Review History
Test plan
Closes #166
🤖 Generated with Claude Code