Skip to main content
Glama

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
NameRequiredDescriptionDefault
commandYesPub subcommand to execute
argsNoArguments for the pub subcommand
workingDirNoWorking directory for the command

Implementation Reference

  • 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
      };
    }
  • 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);

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/egyleader/dart-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server