Skip to content

Commit 0c40512

Browse files
committed
feat: update tool abstraction in README
1 parent 5b3208f commit 0c40512

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,26 @@ mcp add resource market-data
156156
3. **Define your tool schemas with automatic validation:**
157157
```typescript
158158
// tools/DataFetcher.ts
159-
import { MCPTool, McpInput } from "mcp-framework";
160-
import { z } from "zod";
161-
162-
const DataFetcherSchema = z.object({
163-
// all fields should have .describe()
164-
url: z.string().url().describe("URL to fetch data from"),
165-
timeout: z.number().positive().default(5000).describe("Request timeout in milliseconds").optional()
166-
});
167-
168-
class DataFetcher extends MCPTool {
169-
name = "data_fetcher";
170-
description = "Fetch data from external APIs";
171-
schema = DataFetcherSchema;
172-
173-
async execute(input: McpInput<this>) {
174-
// Fully typed input with autocomplete support
175-
const { url, timeout = 5000 } = input;
176-
// ... implementation
177-
}
178-
}
159+
import { MCPTool, MCPInput as AddToolInput } from "mcp-framework";
160+
import { z } from "zod";
161+
162+
const AddToolSchema = z.object({
163+
a: z.number().describe("First number to add"),
164+
b: z.number().describe("Second number to add"),
165+
});
166+
167+
class AddTool extends MCPTool {
168+
name = "add";
169+
description = "Add tool description";
170+
schema = AddToolSchema;
171+
172+
async execute(input: AddToolInput<this>) {
173+
const result = input.a + input.b;
174+
return `Result: ${result}`;
175+
}
176+
}
177+
export default AddTool;
178+
179179
```
180180
181181
4. **Build with automatic validation:**

0 commit comments

Comments
 (0)