Skip to main content
Glama
pc-style

MCP Goose Subagents Server

create_goose_recipe

Create reusable Goose recipes to define specialized subagents for development tasks, enabling delegation to autonomous developer teams with custom roles and instructions.

Instructions

Create a reusable Goose recipe for specialized subagents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
recipe_nameYesName of the recipe
roleYesAgent role (e.g., code_reviewer, security_auditor)
instructionsYesDetailed instructions for the agent
extensionsNoList of Goose extensions to enable
parametersNoRecipe parameters

Implementation Reference

  • The main handler function that implements the logic for the 'create_goose_recipe' tool. It constructs a recipe object from inputs, serializes it to YAML, writes it to a file in 'goose-recipes' directory, and returns a success message.
    async createGooseRecipe(args) {
      const { recipe_name, role, instructions, extensions = [], parameters = {} } = args;
    
      const recipe = {
        id: recipe_name,
        version: '1.0.0',
        title: `${role.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase())} Recipe`,
        description: `Specialized subagent for ${role}`,
        instructions: instructions,
        activities: [
          `Perform ${role} tasks`,
          'Analyze and provide feedback',
          'Generate deliverables'
        ],
        extensions: extensions.map(ext => ({
          type: 'builtin',
          name: ext,
          display_name: ext.replace(/_/g, ' ').replace(/\b\w/g, l => l.toUpperCase()),
          timeout: 300,
          bundled: true
        })),
        parameters: Object.entries(parameters).map(([key, value]) => ({
          key,
          input_type: typeof value,
          requirement: 'optional',
          description: `Parameter for ${key}`,
          default: value
        })),
        prompt: instructions
      };
    
      // Create recipes directory if it doesn't exist
      const recipesDir = path.join(process.cwd(), 'goose-recipes');
      await fs.mkdir(recipesDir, { recursive: true });
    
      // Write recipe file
      const recipeFile = path.join(recipesDir, `${recipe_name}.yaml`);
      const yamlContent = this.objectToYaml(recipe);
      await fs.writeFile(recipeFile, yamlContent);
    
      return {
        content: [
          {
            type: 'text',
            text: `Successfully created Goose recipe "${recipe_name}" at ${recipeFile}\n\nRecipe details:\n- Role: ${role}\n- Extensions: ${extensions.join(', ') || 'none'}\n- Parameters: ${Object.keys(parameters).join(', ') || 'none'}\n\nTo use this recipe, set GOOSE_RECIPE_PATH environment variable to the recipes directory or place the recipe in your working directory.`
          }
        ]
      };
    }
  • The input schema definition for the 'create_goose_recipe' tool, provided in the ListTools response.
      name: 'create_goose_recipe',
      description: 'Create a reusable Goose recipe for specialized subagents',
      inputSchema: {
        type: 'object',
        properties: {
          recipe_name: {
            type: 'string',
            description: 'Name of the recipe'
          },
          role: {
            type: 'string',
            description: 'Agent role (e.g., code_reviewer, security_auditor)'
          },
          instructions: {
            type: 'string',
            description: 'Detailed instructions for the agent'
          },
          extensions: {
            type: 'array',
            items: { type: 'string' },
            description: 'List of Goose extensions to enable'
          },
          parameters: {
            type: 'object',
            description: 'Recipe parameters'
          }
        },
        required: ['recipe_name', 'role', 'instructions']
      }
    },
  • src/index.js:151-152 (registration)
    Registration/dispatch in the CallToolRequestSchema handler's switch statement, routing calls to the createGooseRecipe handler.
    case 'create_goose_recipe':
      return await this.createGooseRecipe(args);
  • Helper utility function to convert JavaScript objects to YAML format, specifically used by createGooseRecipe to serialize the recipe.
    objectToYaml(obj, indent = 0) {
      let yaml = '';
      const spaces = '  '.repeat(indent);
    
      for (const [key, value] of Object.entries(obj)) {
        if (value === null || value === undefined) continue;
    
        if (Array.isArray(value)) {
          yaml += `${spaces}${key}:\n`;
          for (const item of value) {
            if (typeof item === 'object') {
              yaml += `${spaces}- \n${this.objectToYaml(item, indent + 1).split('\n').map(line => line ? `${spaces}  ${line}` : '').join('\n')}\n`;
            } else {
              yaml += `${spaces}- ${item}\n`;
            }
          }
        } else if (typeof value === 'object') {
          yaml += `${spaces}${key}:\n${this.objectToYaml(value, indent + 1)}`;
        } else if (typeof value === 'string' && value.includes('\n')) {
          yaml += `${spaces}${key}: |\n${value.split('\n').map(line => `${spaces}  ${line}`).join('\n')}\n`;
        } else {
          yaml += `${spaces}${key}: ${value}\n`;
        }
      }
    
      return yaml;
    }

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/pc-style/goose-mcp'

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