Conversation
…CP servers (#114) Add adapters/fastmcp.py with utilities to bridge FastMCP servers and contextweaver Catalogs: - fastmcp_tool_to_selectable() — convert FastMCP tool definition dicts to SelectableItem, with 2-segment namespace inference matching FastMCP composition conventions and tag mapping from meta.tags - fastmcp_tools_to_catalog() — batch-convert tool definitions into a populated Catalog with namespace-scoped filtering - load_fastmcp_catalog() — async live discovery from any FastMCP source (FastMCP instance, URL, file path, config dict, Client) via tools/list - infer_fastmcp_namespace() — FastMCP-aware namespace inference accepting 2+ underscore-delimited segments (vs 3+ in generic MCP adapter) - contextweaver[fastmcp] optional extra (fastmcp>=2.0) - Example recipe in examples/fastmcp_adapter_demo.py - 22 new tests covering namespace inference, tag mapping, schema preservation, annotations, catalog building, and import guard
There was a problem hiding this comment.
Pull request overview
Adds a FastMCP-to-Catalog adapter so FastMCP servers (and their tools/list outputs) can be converted into contextweaver SelectableItems and loaded into a Catalog, with an optional extra for live discovery via fastmcp.Client.
Changes:
- Introduces
src/contextweaver/adapters/fastmcp.pywith namespace inference, tool conversion, catalog building, and async live discovery. - Exposes the new adapter functions via
src/contextweaver/adapters/__init__.pyand adds afastmcpoptional extra inpyproject.toml. - Adds FastMCP-focused tests and an example demo script, plus a CHANGELOG entry.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/contextweaver/adapters/fastmcp.py |
New FastMCP adapter (namespace inference, conversion, catalog creation, async discovery). |
src/contextweaver/adapters/__init__.py |
Re-exports FastMCP adapter public API. |
pyproject.toml |
Adds contextweaver[fastmcp] optional dependency group. |
tests/test_adapters.py |
Adds tests for FastMCP namespace inference, conversion, catalog building, and import guard. |
examples/fastmcp_adapter_demo.py |
Adds a standalone demo for dict-based conversion and catalog usage. |
CHANGELOG.md |
Documents the new adapter under [Unreleased]. |
…cstring, update module map docs
…tests, add model_dump comment
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Closes #114
Adds
adapters/fastmcp.py— a bridge between FastMCP servers and contextweaverCatalogobjects. Converts FastMCP tool definitions intoSelectableItems with namespace inference, tag mapping, and schema preservation, and provides live server discovery via the FastMCPClient.What changed
src/contextweaver/adapters/fastmcp.py(new) — core module with:infer_fastmcp_namespace()— 2-segment namespace inference matching FastMCP's{namespace}_{name}composition convention (vs 3+ in the generic MCP adapter)fastmcp_tool_to_selectable()— convert tool definition dicts toSelectableItem, delegating annotation/schema parsing to the existingmcp_tool_to_selectable(), then adjusting id, namespace, name, and tagsfastmcp_tools_to_catalog()— batch-convert to a populatedCatalogload_fastmcp_catalog()— async live discovery from any FastMCP source (server instance, URL, file path, config dict, existing Client) viatools/listsrc/contextweaver/adapters/__init__.py— re-exports new public namespyproject.toml— addscontextweaver[fastmcp]optional extra (fastmcp>=2.0)tests/test_adapters.py— 22 new tests: namespace inference, tag mapping, schema preservation, annotations, catalog building, import guardexamples/fastmcp_adapter_demo.py(new) — standalone example showing namespace inference, tool conversion, catalog building, filtering, and hydrationCHANGELOG.md— entry under[Unreleased] / AddedWhy
FastMCP powers ~70% of MCP servers. Without a direct bridge, users must manually convert each tool definition—this friction blocks adoption. The adapter reuses
mcp_tool_to_selectable()internally and adds FastMCP-specific namespace inference and tag mapping on top.How verified
Tradeoffs / risks
infer_fastmcp_namespaceaccepts 2-segment underscore names (e.g.github_search→ ns=github), which is more aggressive than the generic MCP heuristic. This matches FastMCP composition conventions but may over-infer for non-FastMCP tools — users can passnamespace=to override.load_fastmcp_catalogis async (matching thecontext/async-first convention). Callers in sync contexts needasyncio.run().Checklist
make citargets pass locally (fmt, lint, type, test, example, demo)CHANGELOG.mdupdated under[Unreleased]print()in library code__init__.py