Skip to main content
Glama

get-block-content

Fetch code block content from authenticated URLs to retrieve UI component implementations for development workflows.

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

TableJSON Schema
NameRequiredDescriptionDefault
endpointYes
typeYes

Implementation Reference

  • The handler function for the 'get-block-content' tool. It constructs a URL by appending the 'type' query parameter to the endpoint, fetches the data using apiClient.get, and returns the response content formatted as MCP text content.
    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");
        }
    }
  • Input schema defining required parameters 'endpoint' (string) and 'type' (string) using Zod.
    inputSchema: { endpoint: z.string(), type: z.string() }
  • src/index.ts:176-206 (registration)
    Registers the 'get-block-content' tool with the MCP server, providing name, metadata (title, description, inputSchema), and the handler function.
    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");
            }
        }
    );
  • Definition of the apiClient used in the handler. It provides HTTP methods including 'get' which performs authenticated fetch requests to the FlyonUI API base URL.
    export const apiClient: HttpClient = {
        get: createMethod("GET"),
        post: createMethod("POST"),
        put: createMethod("PUT"),
        delete: createMethod("DELETE"),
        patch: createMethod("PATCH"),
    };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/themeselection/flyonui-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server