-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor mcp tools to use FastMCP composition #25
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,32 @@ | ||
| """ | ||
| MCP Tools for LamPyrid. | ||
|
|
||
| This module coordinates the registration of all MCP tools organized by domain. | ||
| This module coordinates the composition of all MCP tool servers organized by domain. | ||
| Uses FastMCP's native import_server() for static server composition. | ||
| """ | ||
|
|
||
| from fastmcp import FastMCP | ||
|
|
||
| from ..clients.firefly import FireflyClient | ||
| from .accounts import register_tools as register_account_tools | ||
| from .budgets import register_tools as register_budget_tools | ||
| from .transactions import register_tools as register_transaction_tools | ||
| from .accounts import create_accounts_server | ||
| from .budgets import create_budgets_server | ||
| from .transactions import create_transactions_server | ||
|
|
||
|
|
||
| def register_all_tools(mcp: FastMCP, client: FireflyClient) -> None: | ||
| async def compose_all_servers(mcp: FastMCP, client: FireflyClient) -> None: | ||
| """ | ||
| Register all MCP tools with the FastMCP server. | ||
|
|
||
| This function coordinates tool registration from all domain modules: | ||
| - Account management tools (accounts.py) | ||
| - Transaction management tools (transactions.py) | ||
| - Budget management tools (budgets.py) | ||
| Compose all domain-specific MCP servers into the main server using static composition. | ||
|
|
||
| Args: | ||
| mcp: The FastMCP server instance | ||
| mcp: The main FastMCP server instance | ||
| client: The FireflyClient instance for API interactions | ||
| """ | ||
| # Import registration functions from each tool module | ||
|
|
||
| # Register tools from each domain | ||
| register_account_tools(mcp, client) | ||
| register_transaction_tools(mcp, client) | ||
| register_budget_tools(mcp, client) | ||
| # Create standalone servers for each domain | ||
| accounts_server = create_accounts_server(client) | ||
| transactions_server = create_transactions_server(client) | ||
| budgets_server = create_budgets_server(client) | ||
|
|
||
| # Import all servers into the main server without prefixes (static composition) | ||
| await mcp.import_server(accounts_server) | ||
| await mcp.import_server(transactions_server) | ||
| await mcp.import_server(budgets_server) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.