@W-22571806 Set up MCP Apps dependencies and basic server structure#365
Open
jarhun88 wants to merge 4 commits into
Open
@W-22571806 Set up MCP Apps dependencies and basic server structure#365jarhun88 wants to merge 4 commits into
jarhun88 wants to merge 4 commits into
Conversation
Refactors tool registration to support both standard MCP tools and MCP Apps tools with interactive UIs. Tools can now optionally declare an `app` property with UI metadata, enabling rich client-side interactions. Changes: - Add `AppDetails` type with `name` and `resourceUri` fields - Extend `WebToolParams` to include optional `app` field - Extract `_registerTool` and `_registerAppTool` helper methods for clarity - Conditionally register tools based on presence of `app` property - Import and assign `registerAppTool` from @modelcontextprotocol/ext-apps - Add test coverage for app tool registration flow When a tool defines `app`, it's registered via `registerAppTool` with `_meta.ui.resourceUri` pointing to the app resource. Standard tools continue to use the existing `registerTool` path.
Completes MCP Apps infrastructure by implementing resource registration alongside tool registration. When a tool has an `app` property, both the tool metadata and its HTML/JS bundle are registered with the MCP server. Changes: - Add `html` field to `AppDetails` type for UI bundle content - Implement `registerAppResource` call in `_registerAppTool` helper - Register app resources with RESOURCE_MIME_TYPE from ext-apps SDK - Add `invariant` check for app details presence (programming error guard) - Assign `registerAppResource` from ext-apps to make it available - Export `AppDetails` type for external reuse - Add test coverage for resource registration - Remove unused `McpUiReadResourceCallback` import Resource registration uses the same `resourceUri` as the tool's `_meta.ui` field, creating the link between tool invocation and UI rendering. The resource callback returns the HTML bundle when the host requests it. Type suppression note: CJS/ESM module resolution conflict in SDK causes harmless type error. Code works correctly at runtime.
Gate the registration of tools with app properties behind the 'mcp-apps' feature flag. When the feature flag is enabled and a tool has an app property, it is registered as an app tool via registerAppTool. Otherwise, it is registered as a standard tool. Changes: - Check 'mcp-apps' feature flag before registering app tools - Register as standard tool when feature flag is off - Use tool.name as resource name instead of resourceUri for better clarity - Add tests for both feature flag enabled and disabled scenarios - Use stable mock instance pattern for feature gate testing
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.
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of
the pull request.
Pull Request Template
Description
New Tool Type: App Tools
Registration Flow
Added _registerAppTool() method that:
Feature Flag Gating
No tools are registered as app tools yet.
Motivation and Context
Type of Change
How Has This Been Tested?
Related Issues
Checklist
npm run version. For example,use
npm run version:patchfor a patch version bump.environment variable or changing its default value.
Contributor Agreement
By submitting this pull request, I confirm that:
its Contribution Checklist.