Intermediate
Bridge an MCP Server or Custom Tool
Bridge an MCP Server or Custom Tool — Learn how to build intermediate dsh plugins.
Tool vs command: who calls whom
A command is triggered by the user through the UI. A tool is called by the model itself when it decides a function would help. If you want the agent to act on its own, you register a tool.
Path A — register a custom tool
ctx.tools.register({
name: 'read_local_file',
description: 'Read a text file from the workspace',
parameters: {
type: 'object',
properties: { path: { type: 'string' } },
required: ['path'],
},
async execute(args) {
return { ok: true, content: await fs.readFile(args.path, 'utf8') };
},
});Three details matter: a clear description (it steers model selection), a strict JSON Schema for parameters, and structured error returns.