Skip to content

feat: MCP tools and prompt factory#7

Merged
tymondesigns merged 4 commits intomainfrom
feat/mcp-client
Sep 9, 2025
Merged

feat: MCP tools and prompt factory#7
tymondesigns merged 4 commits intomainfrom
feat/mcp-client

Conversation

@tymondesigns
Copy link
Copy Markdown
Contributor

@tymondesigns tymondesigns commented Aug 15, 2025

This pull request introduces comprehensive support for the Model Context Protocol (MCP) in the Cortex PHP package. The main changes include adding a new MCP server manager, integrating MCP prompt and tool factories, and updating configuration to support multiple MCP servers. Additionally, the codebase now provides a toolkit for dynamically loading MCP tools, and standardizes tool invocation signatures across several classes.

MCP Integration and Server Management:

  • Added the php-mcp/client dependency to composer.json, enabling MCP protocol support.
  • Introduced a new McpServerManager class for managing multiple MCP server connections, with corresponding service provider registration and a new McpServer facade for easy access. [1] [2] [3] [4]

Configuration Updates:

  • Updated config/cortex.php to allow configuration of multiple MCP servers and to select the MCP server used for prompts via environment variables. [1] [2]

Prompt and Tool Factories:

  • Refactored the MCP prompt factory (McpPromptFactory) to use the new MCP client, dynamically fetch prompt definitions, build input schemas, and compile prompt messages. [1] [2]
  • Added a new McpTool class for invoking MCP tools, including schema validation and dynamic tool definition loading, and a McpToolKit class for loading all available tools from an MCP server. [1] [2]

Tool Invocation Standardization:

  • Updated several tool classes to make the $toolCall argument in invoke methods optional, improving interface consistency. [1] [2] [3] [4] [5]

Minor Improvements:

  • Added a more precise return type annotation to the prompt helper function.
  • Removed unused imports and an obsolete test from PlaygroundTest.php. [1] [2]

@tymondesigns tymondesigns changed the title feat: MCP Client and prompt factory feat: MCP tools and prompt factory Sep 2, 2025
@tymondesigns tymondesigns marked this pull request as ready for review September 9, 2025 07:30
@tymondesigns tymondesigns merged commit 2039652 into main Sep 9, 2025
6 checks passed
@tymondesigns tymondesigns deleted the feat/mcp-client branch December 29, 2025 00:58
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.

1 participant