dart-package
Manage Dart packages using pub commands like get, upgrade, add, remove, and publish to handle dependencies and package operations in Dart/Flutter projects.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| command | Yes | Pub subcommand to execute | |
| args | No | Arguments for the pub subcommand | |
| workingDir | No | Working directory for the command |
Implementation Reference
- src/tools/pub.ts:12-28 (handler)The main handler function for the 'dart-package' tool. It executes the specified pub subcommand (like 'get', 'add', etc.) using the dart-executor utility and returns the output.export async function pub({ command, args = [], workingDir }: z.infer<typeof pubSchema>) { // If workingDir is provided, ensure it's absolute const absoluteWorkingDir = workingDir ? toAbsolutePath(workingDir) : workingDir; const { stdout, stderr } = await executeDartCommand('pub', [command, ...args], absoluteWorkingDir); return { content: [ { type: "text" as const, text: stdout || stderr } ], isError: !!stderr }; }
- src/tools/pub.ts:5-10 (schema)Zod schema defining the input parameters for the 'dart-package' tool: command (pub subcommand), optional args, and optional working directory.export const pubSchema = z.object({ command: z.enum(['get', 'upgrade', 'outdated', 'add', 'remove', 'publish', 'deps', 'downgrade', 'cache', 'run', 'global']) .describe('Pub subcommand to execute'), args: z.array(z.string()).optional().describe('Arguments for the pub subcommand'), workingDir: z.string().optional().describe('Working directory for the command') });
- src/index.ts:40-40 (registration)Registration of the 'dart-package' tool in the MCP server, linking the name to pubSchema and the pub handler function.server.tool('dart-package', pubSchema.shape, pub);