Skip to content

Conversation

@KedoKudo
Copy link
Collaborator

@KedoKudo KedoKudo commented Dec 7, 2025

Summary

Implements Issue #166 - MCP server module 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

Review History

Iteration Verdict Key Fixes
1 NEEDS REWORK Blind exception, deprecated imports, dead code
2 NEEDS REWORK Python 3.10+ union syntax, RuntimeError handling
3 APPROVED All issues resolved

Test plan

  • All 1168 tests pass
  • Ruff linting passes
  • Pre-commit hooks pass
  • CI pipeline passes

Closes #166

🤖 Generated with Claude Code

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>
@KedoKudo KedoKudo changed the base branch from main to feature/163-mcp-integration December 7, 2025 02:10
@KedoKudo KedoKudo requested a review from Copilot December 7, 2025 02:11
@KedoKudo KedoKudo self-assigned this Dec 7, 2025
Copy link
Contributor

Copilot AI left a 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>
Copy link
Contributor

Copilot AI left a 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.

@KedoKudo KedoKudo merged commit cffc4f8 into feature/163-mcp-integration Dec 7, 2025
8 checks passed
@KedoKudo KedoKudo deleted the feature/166-mcp-server-module branch December 7, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants