set-api-url
Configure the API base URL to establish connection with PI Dashboard resources for managing categories and charts through the MCP server.
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:312-345 (registration)Full registration of the 'set-api-url' tool, including input schema validation with Zod and the complete inline handler function that validates the URL, sets the global API_BASE_URL and flags, and returns success/error messages.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)}` }] }; } });