Skip to main content
Glama
dojoengine

Sensei MCP

by dojoengine

dojo_config

Configure Dojo projects by setting up Scarb.toml, managing permissions, creating profile files, defining namespaces, and handling external contracts and dependencies with Sensei MCP’s guidance.

Instructions

Essential guidance for configuring Dojo projects. Use this when setting up Scarb.toml, creating dojo profile files, configuring permissions, setting up namespaces, or managing external contracts and dependencies.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for executing the 'dojo_config' tool (and all prompt-based tools). Substitutes input variables into the prompt template, adds Dojo-specific documentation references and nudges based on tool name containing 'dojo' and content analysis, then returns the processed text.
    // Create tool handler that replaces variables and returns the result
    const toolHandler = async (
      inputs: Record<string, string>,
      // eslint-disable-next-line @typescript-eslint/no-unused-vars
      _extra: Record<string, unknown>,
    ): Promise<CallToolResult> => {
      const span = Logger.span('toolExecution', { tool: toolName });
      try {
        let finalContent = processedContent;
    
        // Replace each variable with its value
        for (const variable of variables) {
          const value = inputs[variable] || '';
          const pattern = new RegExp(`\\{\\{${variable}\\}\\}`, 'g');
          finalContent = finalContent.replace(pattern, value);
        }
    
        // If there's a generic input and no specific {{input}} variable,
        // append it to the end
        if (inputs.input && !variables.includes('input')) {
          finalContent = `${finalContent}\n\n${inputs.input}`;
        }
    
        // Add the Dojo documentation nudge if this is a Dojo-related tool
        // We determine this based on the tool name or the input content
        const topic = toolName.toLowerCase().includes('dojo')
          ? toolName.replace('dojo_', '')
          : undefined;
    
        // Use the input content for context if available
        const inputContext = inputs.input || '';
    
        // If this is for Dojo, first add documentation references to the content
        if (toolName.toLowerCase().includes('dojo')) {
          finalContent = addDojoDocReferences(finalContent);
        }
    
        // Then add the documentation nudge based on the content and topic
        finalContent = addDojoDocsNudge(finalContent + inputContext, topic);
    
        span.end('success');
        return {
          content: [
            {
              type: 'text' as const,
              text: finalContent,
            },
          ],
        };
      } catch (error) {
        Logger.error(`Tool execution failed: ${toolName}`, error);
        span.end('error');
        throw error;
      }
    };
  • Dynamically generates the Zod input schema for the tool based on variables extracted from the prompt content ({{var}} patterns). All variables are optional strings.
    export function generateInputSchema(variables: string[]): ZodRawShape {
      const schemaObj: Record<string, z.ZodTypeAny> = {};
    
      // Add all other variables
      for (const variable of variables) {
        schemaObj[variable] = z.string().optional();
      }
    
      // Add a dummy parameter to ensure the schema is not empty
      if (Object.keys(schemaObj).length === 0) {
        schemaObj._ = z
          .string()
          .optional()
          .describe('Dummy parameter for no-parameter tools');
      }
    
      return schemaObj;
    }
  • src/prompts.ts:473-485 (registration)
    Registers the tool on the MCP server using server.tool(), with dynamic toolName (from metadata.toolName or filename), optional description from metadata, dynamic schema, and the shared handler. Called for each prompt file with registerAsTool: true.
    // Register the tool
    if (metadata.description) {
      // With description
      server.tool(
        toolName,
        metadata.description,
        schemaObj as ZodRawShape,
        toolHandler,
      );
    } else {
      // Without description
      server.tool(toolName, schemaObj, toolHandler);
    }
  • Helper function called in the handler for Dojo tools to append topic-specific documentation nudges, including specific handling for 'config' topics relevant to dojo_config tool.
    export function addDojoDocsNudge(content: string, topic?: string): string {
      // Keywords that indicate code writing or verification tasks
      const modelKeywords = [
        'model',
        'models',
        'entity',
        'entities',
        'data structure',
        'schema',
      ];
      const logicKeywords = [
        'system',
        'systems',
        'logic',
        'game logic',
        'function',
        'functions',
        'contract',
      ];
      const configKeywords = [
        'config',
        'configuration',
        'scarb',
        'toml',
        'profile',
        'deployment',
      ];
    
      // Check if the content contains any of the keywords
      const hasModelKeywords = modelKeywords.some((keyword) =>
        content.toLowerCase().includes(keyword.toLowerCase()),
      );
      const hasLogicKeywords = logicKeywords.some((keyword) =>
        content.toLowerCase().includes(keyword.toLowerCase()),
      );
      const hasConfigKeywords = configKeywords.some((keyword) =>
        content.toLowerCase().includes(keyword.toLowerCase()),
      );
    
      // Customize nudge based on the specific topic
      let nudge = '';
    
      if (topic) {
        // If a specific topic is provided
        if (topic.toLowerCase().includes('model')) {
          nudge =
            '\n\n📚 **Verify your model code against the [Dojo Models documentation](https://www.dojoengine.org/framework/models). Make sure to implement proper traits and follow entity relationships best practices.**';
        } else if (
          topic.toLowerCase().includes('logic') ||
          topic.toLowerCase().includes('system')
        ) {
          nudge =
            '\n\n📚 **Verify your system logic against the [Dojo Systems documentation](https://www.dojoengine.org/framework/world/systems). Ensure correct world state management and authorization patterns.**';
        } else if (topic.toLowerCase().includes('config')) {
          nudge =
            '\n\n📚 **Verify your configuration against the [Dojo Config documentation](https://www.dojoengine.org/framework/config). Check for proper Scarb.toml setup and profile configuration.**';
        }
      } else {
        // Determine topic based on keyword presence
        if (hasModelKeywords) {
          nudge =
            '\n\n📚 **Verify your model code against the [Dojo Models documentation](https://www.dojoengine.org/framework/models). Make sure to implement proper traits and follow entity relationships best practices.**';
        } else if (hasLogicKeywords) {
          nudge =
            '\n\n📚 **Verify your system logic against the [Dojo Systems documentation](https://www.dojoengine.org/framework/world/systems). Ensure correct world state management and authorization patterns.**';
        } else if (hasConfigKeywords) {
          nudge =
            '\n\n📚 **Verify your configuration against the [Dojo Config documentation](https://www.dojoengine.org/framework/config). Check for proper Scarb.toml setup and profile configuration.**';
        }
      }
    
      // Add a general Dojo nudge if no specific topic was detected
      if (!nudge && (hasModelKeywords || hasLogicKeywords || hasConfigKeywords)) {
        nudge =
          '\n\n📚 **Verify your Dojo code against the [official documentation](https://www.dojoengine.org/overview). Follow best practices for building provable games and applications.**';
      }
    
      return nudge ? content + nudge : content;
    }
  • Helper function called in the handler for Dojo tools to append relevant Dojo documentation links based on content patterns, with specific config-related detection for dojo_config.
    export function addDojoDocReferences(content: string): string {
      // Don't modify content that already has documentation references
      if (
        content.includes('dojoengine.org/framework') ||
        content.includes('dojoengine.org/toolchain')
      ) {
        return content;
      }
    
      // Check for different types of Dojo content
      const hasModelContent =
        content.includes('#[dojo::model]') ||
        content.includes('#[key]') ||
        content.includes('derive(Model') ||
        content.includes('derive(Drop, Serde)');
    
      const hasSystemContent =
        content.includes('#[dojo::contract]') ||
        content.includes('world.read_model') ||
        content.includes('world.write_model') ||
        content.includes('self.world(');
    
      const hasConfigContent =
        content.includes('Scarb.toml') ||
        content.includes('dojo_') ||
        content.includes('[writers]') ||
        content.includes('[target.starknet-contract]');
    
      // Add appropriate documentation references based on content type
      if (hasModelContent) {
        return (
          content +
          '\n\n---\n**Reference Documentation:**\n' +
          '- [Models Overview](https://www.dojoengine.org/framework/models)\n' +
          '- [Entities in Dojo](https://www.dojoengine.org/framework/models/entities)\n' +
          '- [Model Introspection](https://www.dojoengine.org/framework/models/introspect)'
        );
      } else if (hasSystemContent) {
        return (
          content +
          '\n\n---\n**Reference Documentation:**\n' +
          '- [Systems](https://www.dojoengine.org/framework/world/systems)\n' +
          '- [World API](https://www.dojoengine.org/framework/world/api)\n' +
          '- [Authorization](https://www.dojoengine.org/framework/authorization)'
        );
      } else if (hasConfigContent) {
        return (
          content +
          '\n\n---\n**Reference Documentation:**\n' +
          '- [Configuration Guide](https://www.dojoengine.org/framework/config)\n' +
          '- [Sozo Commands](https://www.dojoengine.org/toolchain/sozo)\n' +
          '- [World Contract](https://www.dojoengine.org/framework/world)'
        );
      }
    
      // If content has cairo code but not specific Dojo patterns, add general Dojo reference
      if (
        content.includes('fn ') &&
        content.includes('struct ') &&
        content.includes('impl ')
      ) {
        return (
          content +
          '\n\n---\n**Reference Documentation:**\n' +
          '- [Dojo Documentation](https://www.dojoengine.org/overview)'
        );
      }
    
      return content;
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description mentions 'guidance' and configuration activities but doesn't clarify whether this tool performs actions, provides information, modifies files, or requires specific permissions. It fails to disclose key behavioral traits like whether it's read-only, destructive, or has side effects, which is a significant gap for a configuration tool with zero annotation coverage.

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

Conciseness3/5

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

The description is two sentences: the first states the purpose, and the second provides usage guidelines. It's reasonably concise but could be more front-loaded with a clearer action verb. The phrase 'Essential guidance' is somewhat vague, and the list of configuration activities feels like it's trying to cover too much ground without clarifying the tool's core function. It's adequately structured but not optimally efficient.

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 the complexity of configuration tools and the lack of annotations and output schema, the description is incomplete. It doesn't explain what the tool actually does (e.g., returns configuration templates, validates settings, applies changes) or what users can expect as a result. For a tool with no structured data to rely on, the description should provide more complete context about behavior and outcomes.

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

Parameters4/5

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

The tool has 0 parameters with 100% schema description coverage, so the schema fully documents the absence of parameters. The description doesn't need to add parameter information, and it appropriately doesn't mention any parameters. This meets the baseline of 4 for tools with no parameters, as there's no gap to compensate for.

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

Purpose3/5

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

The description states the tool provides 'essential guidance for configuring Dojo projects' which gives a general purpose, but it's vague about what specific action the tool performs. It lists several configuration activities (setting up Scarb.toml, creating profile files, etc.) but doesn't specify whether this tool performs these actions, helps with them, or provides information about them. The purpose is clear enough to understand the domain but lacks specificity about the tool's actual function.

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

Usage Guidelines4/5

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

The description explicitly states 'Use this when' followed by a list of configuration scenarios, providing clear context for when to invoke this tool. However, it doesn't mention when NOT to use it or how it differs from sibling tools like dojo_101, dojo_logic, or dojo_model, which might also relate to Dojo project configuration. The guidance is helpful but lacks sibling differentiation.

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

Related 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/dojoengine/sensei-mcp'

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