set-api-url
Use this tool to configure the API base URL for all requests in the PI API MCP Server, enabling secure access to PI Dashboard resources such as categories and charts.
Instructions
Set the API base URL for all requests
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | API base URL (e.g., http://localhost:8224/pi/api/v2) |
Implementation Reference
- build/index.js:314-345 (handler)The handler function for the 'set-api-url' tool. It validates the provided URL, sets the global API_BASE_URL variable, updates configuration flags, and returns a success or error message.}, 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)}` }] }; } });
- build/index.js:313-313 (schema)Zod schema defining the input parameter 'url' as a string with description.url: z.string().describe("API base URL (e.g., http://localhost:8224/pi/api/v2)")
- build/index.js:312-312 (registration)The server.tool call registering the 'set-api-url' tool with its name, description, schema, and inline handler function.server.tool("set-api-url", "Set the API base URL for all requests", {