summaryrefslogtreecommitdiff
path: root/mcp-servers/token-gated-mcp-server/.claude/commands/create-tool.md
blob: d83e6310ab85d147ed9c17c07238f9beac8e1150 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
allowed-tools: Write, Edit, Read
description: Create a new token-gated tool with proper protection
argument-hint: "<tool-name> <token-id> [tier]"
---

## Create Token-Gated Tool

Create a new FastMCP tool with token protection using the Radius MCP SDK.

Parameters: $ARGUMENTS

## Tool Creation Steps

1. **Parse Arguments**
   - Extract tool name, token ID, and optional tier
   - Validate token ID format
   - Determine appropriate access pattern

2. **Generate Tool Implementation**

```typescript
server.addTool({
  name: '{tool_name}',
  description: '{description} (requires token {token_id})',
  parameters: z.object({
    // Define your parameters here
    input: z.string().describe('Input data'),
    options: z.object({
      format: z.enum(['json', 'text']).optional(),
      verbose: z.boolean().optional()
    }).optional(),
    __evmauth: z.any().optional().describe('Authentication proof')
  }),
  handler: radius.protect({token_id}, async (args) => {
    // Tool implementation
    try {
      // Process the input
      const result = await process{ToolName}(args.input, args.options);
      
      // Return MCP-formatted response
      return {
        content: [{
          type: 'text',
          text: JSON.stringify(result, null, 2)
        }]
      };
    } catch (error) {
      throw new Error(`{tool_name} failed: ${error.message}`);
    }
  })
});
```

3. **Add to Appropriate Tier**
   - Map to correct token tier
   - Update TOOL_REQUIREMENTS mapping
   - Document access requirements

4. **Create Test Case**
   - Unit test for the tool
   - Auth flow test
   - Error handling test

5. **Update Documentation**
   - Add to tool registry
   - Document parameters
   - Include usage examples

## Generate Complete Tool

Based on the arguments provided, create:

1. Tool implementation file
2. Test file
3. Documentation update
4. Integration with existing server

The tool should follow FastMCP best practices and properly integrate with the Radius MCP SDK for token protection.