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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:121-136 (handler)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", }; }, });
- src/utils/index.ts:41-56 (helper)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; }
- src/utils/index.ts:61-92 (helper)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}`; } }