MCPcopy Create free account
hub / github.com/ShipSecAI/studio / getToolInputShape

Function getToolInputShape

packages/component-sdk/src/tool-helpers.ts:174–207  ·  view source on GitHub ↗
(component: ComponentDefinition)

Source from the content-addressed store, hash-verified

172 * This is used to register tools with the MCP server for input validation.
173 */
174export function getToolInputShape(component: ComponentDefinition): ToolInputShape {
175 const shape = getObjectShape(component.inputs);
176 if (!shape) {
177 return {};
178 }
179
180 const actionInputIds = getActionInputIds(component);
181 const filtered: ToolInputShape = {};
182
183 for (const id of actionInputIds) {
184 const schema = shape[id];
185 if (schema) {
186 filtered[id] = schema;
187 }
188 }
189
190 const exposedParamIds = getExposedParameterIds(component);
191 if (exposedParamIds.length > 0) {
192 const paramShape = getObjectShape(component.parameters);
193 if (paramShape) {
194 for (const id of exposedParamIds) {
195 if (filtered[id]) {
196 continue;
197 }
198 const schema = paramShape[id];
199 if (schema) {
200 filtered[id] = schema;
201 }
202 }
203 }
204 }
205
206 return filtered;
207}
208
209/**
210 * Get the JSON Schema for the action inputs only (inputs exposed to the agent).

Callers 2

registerToolsMethod · 0.90

Calls 3

getActionInputIdsFunction · 0.85
getExposedParameterIdsFunction · 0.85
getObjectShapeFunction · 0.70

Tested by

no test coverage detected