Skip to main content
Glama

start_server

Start a development server by specifying the command, process name, and optional port and working directory.

Instructions

Start a development server

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesServer command
portNoPort number
nameYesProcess name for reference
cwdNoWorking directory

Implementation Reference

  • Main handler for start_server tool. Spawns a child process with the given command, optionally sets PORT env var, captures stdout/stderr output, and resolves after a startup delay or on process exit.
    async startServer(args: StartServerArgs): Promise<ToolResult> {
      const { command, port, name, cwd } = args;
      ValidationUtils.validateRequired({ command, name }, ['command', 'name']);
      
      return new Promise((resolve, reject) => {
        const workDir = cwd ? this.workspaceService.resolvePath(cwd) : this.workspaceService.getCurrentWorkspace();
        
        try {
          const proc = spawn(command, [], {
            shell: true,
            cwd: workDir,
            env: { ...process.env, PORT: port?.toString() },
            detached: false,
            stdio: ['pipe', 'pipe', 'pipe']
          });
          
          const processInfo = ProcessUtils.createProcessInfo(proc, command, port, workDir);
          this.activeProcesses.set(name, processInfo);
          
          let output = '';
          let hasResolved = false;
          
          // Set up timeout for process startup
          const startupTimeout = setTimeout(() => {
            if (!hasResolved) {
              hasResolved = true;
              resolve({
                content: [{
                  type: 'text',
                  text: `Server "${name}" started\nCommand: ${command}\nPort: ${port || 'default'}\nWorkspace: ${workDir}\nPID: ${proc.pid}\n\nInitial output:\n${output}`,
                }],
              });
            }
          }, this.startupDelay);
          
          proc.stdout?.on('data', (data) => {
            output += data.toString();
          });
          
          proc.stderr?.on('data', (data) => {
            output += data.toString();
          });
          
          proc.on('error', (error) => {
            clearTimeout(startupTimeout);
            this.activeProcesses.delete(name);
            if (!hasResolved) {
              hasResolved = true;
              reject(new Error(`Failed to start server "${name}": ${error.message}`));
            }
          });
          
          proc.on('exit', (code) => {
            clearTimeout(startupTimeout);
            this.activeProcesses.delete(name);
            if (!hasResolved) {
              hasResolved = true;
              resolve({
                content: [{
                  type: 'text',
                  text: `Server "${name}" exited with code ${code}\nOutput:\n${output}`,
                }],
              });
            }
          });
          
        } catch (error) {
          reject(new Error(`Failed to spawn process: ${error instanceof Error ? error.message : 'Unknown error'}`));
        }
      });
    }
  • TypeScript interface defining the input schema for start_server: command (string), port (optional number), name (string), cwd (optional string).
    export interface StartServerArgs {
      command: string;
      port?: number;
      name: string;
      cwd?: string;
    }
  • src/index.ts:241-242 (registration)
    Registration/dispatch in the main server class. Routes the 'start_server' tool name to processService.startServer(args).
    case 'start_server':
      return await this.processService.startServer(args as StartServerArgs);
  • Tool definition registration with name 'start_server', description, and inputSchema declaring command (string, required), port (number, optional), name (string, required), cwd (string, optional).
    // Process Management
    {
      name: 'start_server',
      description: 'Start a development server',
      inputSchema: {
        type: 'object',
        properties: {
          command: { type: 'string', description: 'Server command' },
          port: { type: 'number', description: 'Port number' },
          name: { type: 'string', description: 'Process name for reference' },
          cwd: { type: 'string', description: 'Working directory' },
        },
        required: ['command', 'name'],
      },
    },
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose any behavioral traits beyond the action. It fails to mention side effects, background execution, server lifecycle, or any safety considerations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence that is efficient and to the point. However, it could be expanded to include critical usage hints without losing conciseness.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no output schema, the description should explain what the agent can expect after invoking the tool (e.g., process ID, URL, background task). It also omits mention of how to manage or stop the server, leaving the agent under-informed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the input schema fully documents all parameters. The description adds no additional meaning beyond what the schema already provides.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Start a development server' uses a specific verb 'start' and identifies the resource as a 'development server'. It clearly distinguishes from sibling tools like 'stop_server' and 'run_command'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'run_command' or 'start_coding_session'. There are no exclusions, prerequisites, or scenario descriptions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/agentics-ai/code-mcp'

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