feat(api): comprehensive Virtual Meta-Server with 12 meta-tools#3978
Open
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Open
feat(api): comprehensive Virtual Meta-Server with 12 meta-tools#3978ecthelion77 wants to merge 1 commit intoIBM:mainfrom
ecthelion77 wants to merge 1 commit intoIBM:mainfrom
Conversation
de459da to
f6712e6
Compare
6 tasks
f6712e6 to
096d1a3
Compare
Contributor
Author
|
Suggested labels: |
096d1a3 to
ccccaab
Compare
096d1a3 to
9611672
Compare
6216fe9 to
18e4b01
Compare
Implements the Virtual Meta-Server feature (IBM#2230) — a tool aggregation layer that enables AI agents to discover and invoke thousands of underlying tools through a unified interface. Meta-tools: - search_tools: hybrid semantic + keyword search with scope filtering - list_tools: paginated tool listing with sorting and filtering - describe_tool: detailed tool info with schema and metadata - execute_tool: tool execution with JSON schema validation and routing - get_tool_categories: aggregated categories with counts - get_similar_tools: vector similarity search for related tools - authorize_gateway: interactive OAuth authorization with token refresh - authorize_all_gateways: one-click authorization for all OAuth gateways - list_resources: paginated MCP resource listing - read_resource: read MCP resource content by URI - list_prompts: paginated MCP prompt listing - get_prompt: prompt template retrieval with optional rendering Features: - OAuth integration: propagates user identity through the call chain - Chained OAuth flow: authorize-all endpoint chains multiple gateways - camelCase normalization for MCP clients - Flat argument tolerance for Copilot Studio - Post-login redirect via cookie with safe path validation - Observability: prompt.render and resource.read spans - JSON serialization: orjson.dumps() for proper JSON output - Admin UI: meta-server checkbox and hide-underlying-tools in server forms - Preserves protect_oauth_config_for_storage() on server update - RBAC enforcement via middleware on all meta endpoints Closes IBM#2230 Supersedes IBM#3653 Signed-off-by: Olivier Gintrand <olivier.gintrand@forterro.com>
18e4b01 to
8a88dee
Compare
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.
🔗 Related Issue
Closes #2230
Supersedes #3653
📝 Summary
This PR implements the Virtual Meta-Server feature — a comprehensive tool aggregation layer that enables AI agents to discover and invoke thousands of underlying tools through a unified interface. It exposes 12 meta-tools to the agent while completely hiding the complexity of the underlying tool ecosystem.
This is a production-tested alternative to PR #3653, with additional features, security hardening, and 2+ weeks of real-world testing with VS Code Copilot and Copilot Studio.
Problem Statement
Traditional MCP architectures expose all tools directly to AI agents, leading to:
Solution — 12 Meta-Tools
Core (same as #3653)
search_tools: hybrid semantic + keyword search with scope filteringlist_tools: paginated tool listing with sorting and filteringdescribe_tool: detailed tool info with schema and metadataexecute_tool: tool execution with JSON schema validation and routingget_tool_categories: aggregated categories with countsget_similar_tools: vector similarity search for related toolsNew (beyond #3653)
authorize_gateway: interactive OAuth authorization with token refreshauthorize_all_gateways: one-click authorization for all OAuth gatewayslist_resources: paginated MCP resource listingread_resource: read MCP resource content by URIlist_prompts: paginated MCP prompt listingget_prompt: prompt template retrieval with optional renderingKey Improvements Over #3653
Security Fixes (vs #3653)
The original PR #3653 introduced several security regressions that this PR avoids:
x-forwarded-internallyheader validation against loopback IP is maintained (the original PR removed this check)protect_oauth_config_for_storage()is called on server updates (the original PR removed this)orjson.dumps()instead of Pythonstr()which produces invalid JSON with single quoteswrapsfromfunctoolsis properly imported (the original PR had aNameErrorat startup)_is_safe_local_path()validation to prevent open redirect attacks🏷️ Type of Change
Test Coverage
📓 Notes
Files Changed (26 files, +6584/-23)
New Files
mcpgateway/meta_server/__init__.py— Package initializationmcpgateway/meta_server/schemas.py— Pydantic models for all 12 meta-toolsmcpgateway/meta_server/service.py— MetaServerService with all handler implementationsmcpgateway/routers/meta_router.py— HTTP endpoints under/meta/*mcpgateway/services/meta_tool_service.py— Business logic for describe/executemcpgateway/services/semantic_search_service.py— Semantic search stub (graceful fallback)mcpgateway/services/vector_search_service.py— Vector search with numpy fallbackmcpgateway/services/embedding_service.py— Embedding stub (no-op without model)mcpgateway/utils/pgvector.py— pgvector compatibility shimmcpgateway/alembic/versions/5126ced48fd0— Migration for meta-server fieldsModified Files
mcpgateway/schemas.py— server_type, hide_underlying_tools, meta_config, meta_scope fieldsmcpgateway/db.py— ToolEmbedding model + meta-server fields on Servermcpgateway/transports/streamablehttp_transport.py— Tool hiding + meta-tool routingmcpgateway/middleware/rbac.py— Login redirect with ?next= preservationmcpgateway/routers/oauth_router.py— Chained OAuth flow + authorize-all endpointmcpgateway/routers/sso.py— Post-login redirect cookie handlingmcpgateway/services/server_service.py— Meta-server field handlingmcpgateway/services/tool_service.py— Absolute OAuth authorize URLmcpgateway/admin.py— Meta-server fields in admin UImcpgateway/static/admin.js— Meta-server JS configmcpgateway/templates/admin.html— Meta-server form fieldsmcpgateway/templates/gateways_partial.html— Authorize button for non-admin usersmcpgateway/main.py— Router registrationmcpgateway/config.py— semantic_search_rate_limit settingTests
tests/unit/mcpgateway/test_meta_server.py— 2257 lines covering all meta-toolstests/unit/mcpgateway/services/test_meta_tool_service.py— 180 lines for tool serviceMigration & Compatibility
server_type="standard"server_type="meta"