import { definePlugin, defineTool } from "@toolshed/sdk";
import { z } from "zod";
const myTool = defineTool({
path: "my_service.items.list",
name: "List Items",
description: "List items from My Service.",
inputSchema: z.object({
limit: z.number().int().positive().default(10),
}),
outputSchema: z.object({
items: z.array(z.object({
id: z.string(),
name: z.string(),
})),
}),
async handler(ctx, input) {
const token = await ctx.auth.getToken("my-service");
const res = await fetch(`https://api.myservice.com/items?limit=${input.limit}`, {
headers: { Authorization: `Bearer ${token}` },
});
const data = await res.json();
return { items: data };
},
});
const plugin = definePlugin({
id: "my-service",
name: "My Service",
description: "Tools for My Service.",
authProviders: [
{
id: "my-service",
type: "oauth2",
provider: "my-service",
scopes: ["read", "write"],
},
],
tools: [myTool],
});
export default plugin;