MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / registerToolCommands

Function registerToolCommands

src/cli/register-tool-commands.ts:140–194  ·  view source on GitHub ↗
(
  app: Argv,
  catalog: ToolCatalog,
  opts: RegisterToolCommandsOptions,
)

Source from the content-addressed store, hash-verified

138 * Register all tool commands from the catalog with yargs, grouped by workflow.
139 */
140export function registerToolCommands(
141 app: Argv,
142 catalog: ToolCatalog,
143 opts: RegisterToolCommandsOptions,
144): void {
145 const invoker = new DefaultToolInvoker(catalog);
146 const toolsByWorkflow = groupToolsByWorkflow(catalog);
147 const cliExposedWorkflowIds = opts.cliExposedWorkflowIds ?? [...toolsByWorkflow.keys()];
148 const workflowNames = opts.workflowNames ?? [...toolsByWorkflow.keys()];
149 const workflowMetadata = getWorkflowMetadataFromManifest();
150
151 for (const workflowName of workflowNames) {
152 const tools = toolsByWorkflow.get(workflowName) ?? [];
153 const workflowMeta = workflowMetadata[workflowName];
154 const workflowDescription = workflowMeta?.name ?? workflowName;
155
156 app.command(
157 workflowName,
158 workflowDescription,
159 (yargs) => {
160 // Hide root-level options from workflow help
161 yargs
162 .option('log-level', { hidden: true })
163 .option('style', { hidden: true })
164 .option('file-path-render-style', { hidden: true });
165
166 // Register each tool as a subcommand under this workflow
167 for (const tool of tools) {
168 registerToolSubcommand(yargs, tool, invoker, opts, cliExposedWorkflowIds);
169 }
170
171 if (tools.length === 0) {
172 const hint =
173 workflowName === 'xcode-ide'
174 ? buildXcodeIdeNoCommandsMessage(workflowName)
175 : `No CLI commands are currently exposed for '${workflowName}'.`;
176
177 yargs.epilogue(hint);
178 return yargs.help();
179 }
180
181 return yargs.demandCommand(1, '').help();
182 },
183 () => {
184 if (tools.length === 0) {
185 console.error(
186 workflowName === 'xcode-ide'
187 ? buildXcodeIdeNoCommandsMessage(workflowName)
188 : `No CLI commands are currently exposed for '${workflowName}'.`,
189 );
190 }
191 },
192 );
193 }
194}
195
196/**
197 * Register a single tool as a subcommand.

Callers 3

buildYargsAppFunction · 0.90
createAppFunction · 0.90

Calls 5

groupToolsByWorkflowFunction · 0.90
registerToolSubcommandFunction · 0.85
getMethod · 0.80

Tested by 1

createAppFunction · 0.72