Get Block Data
get-block-contentFetch the content of a code block from an authenticated URL by providing endpoint and block type. Use this to retrieve UI component code.
Instructions
Fetch the content of a block from a given URL. Use this tool to retrieve the code block content from the authenticated URL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endpoint | Yes | ||
| type | Yes |
Implementation Reference
- src/index.ts:183-205 (handler)The handler function for the 'get-block-content' tool. It takes endpoint and type parameters, constructs a URL, makes a GET request via apiClient, and returns the block content as JSON.
async ({ endpoint, type }) => { try { const url = endpoint + "?type=" + type; const response = await apiClient.get(url); if (response.status !== 200) { throw new Error(`Failed to fetch block data: ${response.status}`); } return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), } ], }; } catch (error) { console.error("Error fetching block data:", error); throw new Error("Failed to fetch block data"); } } - src/index.ts:181-182 (schema)Input schema for 'get-block-content' using zod: endpoint (string) and type (string) parameters.
inputSchema: { endpoint: z.string(), type: z.string() } }, - src/index.ts:176-206 (registration)Registration of the 'get-block-content' tool via server.registerTool with title, description, inputSchema, and handler.
server.registerTool( "get-block-content", { title: "Get Block Data", description: "Fetch the content of a block from a given URL. Use this tool to retrieve the code block content from the authenticated URL.", inputSchema: { endpoint: z.string(), type: z.string() } }, async ({ endpoint, type }) => { try { const url = endpoint + "?type=" + type; const response = await apiClient.get(url); if (response.status !== 200) { throw new Error(`Failed to fetch block data: ${response.status}`); } return { content: [ { type: "text", text: JSON.stringify(response.data, null, 2), } ], }; } catch (error) { console.error("Error fetching block data:", error); throw new Error("Failed to fetch block data"); } } );