-
Notifications
You must be signed in to change notification settings - Fork 14
feat(component-sdk): add tool mode metadata for agent-callable components #207
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
base: main
Are you sure you want to change the base?
Conversation
13abde0 to
7e4d294
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 7e4d294d12
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| case 'json': | ||
| case 'any': | ||
| return 'object'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not force json/any ports to object in tool schema
portTypeToJsonSchemaType maps both json and any to the JSON Schema type object, but coercePrimitive in ports.ts accepts any value for these port types (strings, numbers, arrays, etc.). This makes the generated MCP inputSchema reject legitimate non-object inputs (e.g., a JSON array or string) or mislead agents about the expected shape. Consider omitting type for these ports or using a permissive schema so tool calls that pass valid non-object JSON aren’t rejected.
Useful? React with 👍 / 👎.
4f4cee6 to
f09bb4d
Compare
…emas
Previously, json/any ports were incorrectly forced to type: 'object' in
MCP tool schemas. This fix uses Zod's built-in toJSONSchema() method
which correctly handles all types:
- z.any() → {} (empty schema = any JSON value)
- z.union([...]) → { anyOf: [...] }
- z.enum([...]) → { type: 'string', enum: [...] }
- z.literal('X') → { type: 'string', const: 'X' }
- z.record(...) → { type: 'object', additionalProperties: {...} }
This also simplifies the code by removing redundant helper functions
and reusing the existing getActionInputIds() function.
Fixes P2 bug in PR #207
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
f09bb4d to
96df26b
Compare
Previously, json/any ports were incorrectly forced to type: 'object' in
MCP tool schemas. This fix uses Zod's built-in toJSONSchema() method
which correctly handles all types:
- z.any() → {} (empty schema = any JSON value)
- z.union([...]) → { anyOf: [...] }
- z.enum([...]) → { type: 'string', enum: [...] }
- z.literal('X') → { type: 'string', const: 'X' }
- z.record(...) → { type: 'object', additionalProperties: {...} }
Changes:
- Use @modelcontextprotocol/sdk for official Tool types
- ToolInputSchema now derives from Tool['inputSchema']
- Simplified code by reusing existing getActionInputIds()
- Removed redundant helper functions
Fixes P2 bug in PR #207
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
96df26b to
f3da236
Compare
…ents ENG-95 - Add PortBindingType and bindingType to ComponentPortMetadata - Add AgentToolConfig and agentTool to ComponentUiMetadata - Create tool-helpers.ts with isAgentCallable, getToolSchema, getCredentialInputIds, getActionInputIds, getToolName, getToolDescription, getToolMetadata - Add comprehensive tests for all helper functions (14 tests) Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
…itecture Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
Previously, json/any ports were incorrectly forced to type: 'object' in
MCP tool schemas. This fix uses Zod's built-in toJSONSchema() method
which correctly handles all types:
- z.any() → {} (empty schema = any JSON value)
- z.union([...]) → { anyOf: [...] }
- z.enum([...]) → { type: 'string', enum: [...] }
- z.literal('X') → { type: 'string', const: 'X' }
- z.record(...) → { type: 'object', additionalProperties: {...} }
Changes:
- Use @modelcontextprotocol/sdk for official Tool types
- ToolInputSchema now derives from Tool['inputSchema']
- Simplified code by reusing existing getActionInputIds()
- Removed redundant helper functions
Fixes P2 bug in PR #207
Signed-off-by: betterclever <paliwal.pranjal83@gmail.com>
f3da236 to
0660362
Compare
Summary
Adds tool mode metadata for agent-callable components, allowing components to be exposed as MCP tools.
Changes
✨ Features
🐛 Bug Fixes
🏗️ Refactoring
Testing
All component-sdk tests pass:
```
126 pass
7 skip
0 fail
```
Type Definitions
```typescript
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
// Uses MCP SDK's official Tool.inputSchema type
export type ToolInputSchema = Tool['inputSchema'];
export interface ToolMetadata {
name: string;
description: string;
inputSchema: ToolInputSchema;
}
```