Skip to main content
Glama

set-api-url

Configure the API endpoint for PI Dashboard by setting the base URL, directing all subsequent API calls to the specified server.

Instructions

Set the API base URL for all requests

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesAPI base URL (e.g., http://localhost:8224/pi/api/v2)

Implementation Reference

  • build/index.js:312-345 (registration)
    Registration of the 'set-api-url' MCP tool using server.tool(), defining the tool name, description, schema with a 'url' parameter, and the async handler function.
    server.tool("set-api-url", "Set the API base URL for all requests", {
        url: z.string().describe("API base URL (e.g., http://localhost:8224/pi/api/v2)")
    }, async ({ url }) => {
        try {
            // Validate URL format
            try {
                new URL(url);
            }
            catch (e) {
                return {
                    isError: true,
                    content: [{
                            type: "text",
                            text: `Invalid URL format. Please provide a valid URL including protocol (http:// or https://).`
                        }]
                };
            }
            API_BASE_URL = url;
            apiUrlSet = true;
            connectionVerified = false;
            return {
                content: [{
                        type: "text",
                        text: `API URL set to: ${url}\n\nNext step: Please authenticate to start using the API.`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error setting API URL: ${getErrorMessage(error)}` }]
            };
        }
    });
  • Input schema for the 'set-api-url' tool: requires a single 'url' string parameter described as 'API base URL (e.g., http://localhost:8224/pi/api/v2)'.
        url: z.string().describe("API base URL (e.g., http://localhost:8224/pi/api/v2)")
    }, async ({ url }) => {
  • Handler function for 'set-api-url'. Validates URL format using new URL(), sets API_BASE_URL and apiUrlSet globals, resets connectionVerified, and returns a success message prompting the user to authenticate.
    }, async ({ url }) => {
        try {
            // Validate URL format
            try {
                new URL(url);
            }
            catch (e) {
                return {
                    isError: true,
                    content: [{
                            type: "text",
                            text: `Invalid URL format. Please provide a valid URL including protocol (http:// or https://).`
                        }]
                };
            }
            API_BASE_URL = url;
            apiUrlSet = true;
            connectionVerified = false;
            return {
                content: [{
                        type: "text",
                        text: `API URL set to: ${url}\n\nNext step: Please authenticate to start using the API.`
                    }]
            };
        }
        catch (error) {
            return {
                isError: true,
                content: [{ type: "text", text: `Error setting API URL: ${getErrorMessage(error)}` }]
            };
        }
    });
  • Global state variable 'apiUrlSet' that tracks whether the API URL has been set (initialized from CLI --api-url arg or via the set-api-url tool).
    let apiUrlSet = !!API_BASE_URL;
    let connectionVerified = false;
  • The authenticatedRequest helper checks apiUrlSet and throws an error referencing the set-api-url tool if the URL hasn't been configured yet.
    if (!apiUrlSet) {
        throw new Error("API URL not set. Please set the API URL using the set-api-url tool.");
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Description implies a global configuration effect but does not disclose persistence, session scope, or side effects. No annotations to supplement behavioral info.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single concise sentence directly states the tool's function with no unnecessary words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple setter with one required parameter and no output, the description fully addresses the context. No additional complexity requires elaboration.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema covers 100% of parameters with a clear description including example. Description adds no significant meaning beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states the action (Set) and resource (API base URL), with global scope implied by 'for all requests'. No sibling tool sets URLs, so it's distinctive.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use or not use this tool. No mention of prerequisites, order of operations, or alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/mingzilla/pi-api-mcp-server'

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