Skip to main content
Glama

show_example

Demonstrate practical examples of MCP features like 'tool_call' or 'resource_read' to help developers understand and implement MCP concepts effectively.

Instructions

Show a practical example of an MCP feature

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureYesThe MCP feature to demonstrate (e.g., 'tool_call', 'resource_read', 'prompt_template')

Implementation Reference

  • Handler function that executes the 'show_example' tool by returning a predefined code example based on the input feature.
      if (name === "show_example" && args) {
        const feature = (args.feature as string).toLowerCase();
        const examples: Record<string, string> = {
          "tool_call": `Here's an example of defining and using a tool:
    
    // Define the tool
    {
      name: "calculate_sum",
      description: "Add two numbers together",
      inputSchema: {
        type: "object",
        properties: {
          a: { type: "number" },
          b: { type: "number" }
        },
        required: ["a", "b"]
      }
    }
    
    // Use the tool
    const result = await server.callTool("calculate_sum", { a: 5, b: 3 });
    // Result: 8`,
    
          "resource_read": `Here's an example of exposing and reading a resource:
    
    // Define the resource
    {
      uri: "file:///docs/guide.md",
      name: "MCP Guide",
      description: "Documentation for MCP concepts",
      mimeType: "text/markdown"
    }
    
    // Read the resource
    const content = await server.readResource("file:///docs/guide.md");`,
    
          "prompt_template": `Here's an example of a prompt template:
    
    {
      name: "code_review",
      description: "Review code for best practices",
      arguments: [
        {
          name: "language",
          description: "Programming language",
          required: true
        },
        {
          name: "code",
          description: "Code to review",
          required: true
        }
      ]
    }
    
    // Generated prompt:
    "Please review this {language} code:\n{code}"`
        };
    
        const example = examples[feature];
        if (!example) {
          return {
            content: [{
              type: "text",
              text: `I don't have an example for "${feature}" yet. Available examples: ${Object.keys(examples).join(", ")}`
            }]
          };
        }
    
        return {
          content: [{
            type: "text",
            text: example
          }]
        };
      }
  • src/index.ts:272-285 (registration)
    Registration of the 'show_example' tool in the listTools response, including its name, description, and input schema.
    {
      name: "show_example",
      description: "Show a practical example of an MCP feature",
      inputSchema: {
        type: "object",
        properties: {
          feature: {
            type: "string",
            description: "The MCP feature to demonstrate (e.g., 'tool_call', 'resource_read', 'prompt_template')",
          }
        },
        required: ["feature"]
      }
    },
  • Schema definition for the 'show_example' tool, specifying the required 'feature' input parameter.
    {
      name: "show_example",
      description: "Show a practical example of an MCP feature",
      inputSchema: {
        type: "object",
        properties: {
          feature: {
            type: "string",
            description: "The MCP feature to demonstrate (e.g., 'tool_call', 'resource_read', 'prompt_template')",
          }
        },
        required: ["feature"]
      }
    },
Install Server

Other Tools

Related Tools

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/qpd-v/mcp-guide'

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