Skip to main content
Glama

build_clarity_smart_contract

Get comprehensive resources for developing Clarity smart contracts on Stacks blockchain, including SIP standards, security patterns, and best practices to guide your contract creation process.

Instructions

Build a Clarity smart contract - returns comprehensive resources for Clarity development including SIP standards, security patterns, and best practices. Use this tool when you need guidance on building smart contracts for Stacks.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler implementation for the 'build_clarity_smart_contract' tool. It reads and returns markdown content from the 'clarity' and 'tokens' resource directories providing guidance for building Clarity smart contracts.
    server.addTool({
      name: "build_clarity_smart_contract",
      description: "Build a Clarity smart contract - returns comprehensive resources for Clarity development including SIP standards, security patterns, and best practices. Use this tool when you need guidance on building smart contracts for Stacks.",
      parameters: z.object({}),
      execute: async () => {
        const content = await readAllMarkdownFromDirectories([
          "clarity",
          "tokens",
        ]);
    
        return {
          text: content || "No content found in clarity and tokens directories.",
          type: "text",
        };
      },
    });
  • src/server.ts:121-136 (registration)
    Registration of the 'build_clarity_smart_contract' tool using FastMCP server.addTool method.
    server.addTool({
      name: "build_clarity_smart_contract",
      description: "Build a Clarity smart contract - returns comprehensive resources for Clarity development including SIP standards, security patterns, and best practices. Use this tool when you need guidance on building smart contracts for Stacks.",
      parameters: z.object({}),
      execute: async () => {
        const content = await readAllMarkdownFromDirectories([
          "clarity",
          "tokens",
        ]);
    
        return {
          text: content || "No content found in clarity and tokens directories.",
          type: "text",
        };
      },
    });
  • Helper function used by the tool handler to read and combine all markdown files from the specified directories ('clarity', 'tokens').
    export async function readAllMarkdownFromDirectories(
      dirNames: string[]
    ): Promise<string> {
      let combinedContent = "";
    
      for (const dirName of dirNames) {
        const dirPath = pathJoin(resourcesDir, dirName);
        const dirContent = await readAllMarkdownFromDirectory(dirPath);
        if (dirContent.trim()) {
          combinedContent += `# ${dirName.toUpperCase()} RESOURCES\n\n`;
          combinedContent += dirContent;
        }
      }
    
      return combinedContent;
    }
  • Supporting helper function that reads all markdown files from a single directory, used by readAllMarkdownFromDirectories.
    export async function readAllMarkdownFromDirectory(
      dirPath: string
    ): Promise<string> {
      let content = "";
    
      try {
        if (!fs.existsSync(dirPath)) {
          return `Directory not found: ${dirPath}`;
        }
    
        const files = fs.readdirSync(dirPath);
        const markdownFiles = files.filter(
          (file: string) => extname(file).toLowerCase() === ".md"
        );
    
        for (const file of markdownFiles) {
          const filePath = pathJoin(dirPath, file);
          try {
            const fileContent = await readFile(filePath, "utf-8");
            content += fileContent + "\n\n---\n\n";
          } catch (error) {
            console.error(`Error reading file ${filePath}:`, error);
            content += `Error reading file: ${file}\n\n---\n\n`;
          }
        }
    
        return content;
      } catch (error) {
        console.error(`Error reading directory ${dirPath}:`, error);
        return `Error reading directory: ${dirPath}`;
      }
    }
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 it 'returns comprehensive resources' but doesn't specify what form these resources take (e.g., documentation links, code snippets, structured data), whether there are rate limits, authentication requirements, or any side effects. For a tool with no annotation coverage, this leaves significant gaps in understanding how the tool behaves.

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

Conciseness5/5

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

The description is efficiently structured in two sentences: the first states the purpose and outputs, the second provides usage guidance. Every word serves a clear function with no redundancy or fluff, making it easy to parse and understand quickly.

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

Completeness3/5

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

Given the tool has no parameters and no output schema, the description adequately covers the basic purpose and usage. However, it lacks details on what the 'comprehensive resources' include (e.g., format, examples) and behavioral aspects like error handling or dependencies. For a guidance tool with many sibling alternatives, more context could help distinguish it better.

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. The description doesn't need to explain parameters, and it appropriately doesn't mention any. Since there are no parameters to document, the baseline score is 4, as the description correctly focuses on the tool's purpose rather than nonexistent inputs.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Build a Clarity smart contract - returns comprehensive resources for Clarity development including SIP standards, security patterns, and best practices.' It specifies the verb ('Build') and resource ('Clarity smart contract') with concrete outputs. However, it doesn't explicitly differentiate from siblings like 'generate_clarity_contract' or 'generate_sip009_template', which appear to be more specific generation tools.

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 provides clear context for when to use the tool: 'Use this tool when you need guidance on building smart contracts for Stacks.' This gives a specific scenario (guidance on building) and domain (Stacks). However, it doesn't mention when NOT to use it or explicitly name alternatives among the many sibling tools, which could help avoid confusion with similar-sounding tools.

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/exponentlabshq/stacks-clarity-mcp'

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