Skip to main content
Glama

check-connection

Verify API URL and authentication validity to ensure secure access to PI Dashboard resources.

Instructions

Check if the current API URL and authentication are valid

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'check-connection' tool. It checks if API URL and auth token are configured, calls verifyConnection() to test the API, and returns success or error messages.
    server.tool("check-connection", "Check if the current API URL and authentication are valid", {}, async () => { try { if (!apiUrlSet || !API_BASE_URL) { return { content: [{ type: "text", text: "API URL not set. Please set the API URL using the set-api-url tool." }] }; } if (!authToken) { return { content: [{ type: "text", text: "Not authenticated. Please authenticate using the authenticate tool." }] }; } // Verify the connection const isConnected = await verifyConnection(); if (isConnected) { return { content: [{ type: "text", text: `✅ Connection successful! The API URL and token are valid. You're ready to use the PI API.` }] }; } else { return { isError: true, content: [{ type: "text", text: `❌ Connection failed. The token might be invalid or expired. Please try to authenticate again.` }] }; } } catch (error) { return { isError: true, content: [{ type: "text", text: `Connection check failed: ${getErrorMessage(error)}` }] }; } });
  • build/index.js:263-263 (registration)
    Registers the 'check-connection' tool on the MCP server with empty input schema (no parameters required).
    server.tool("check-connection", "Check if the current API URL and authentication are valid", {}, async () => {
  • Helper function verifyConnection() called by the check-connection handler to test the API connection via /tokens/keepAlive endpoint.
    async function verifyConnection() { if (!apiUrlSet || !API_BASE_URL) { return false; } if (!authToken) { return false; } try { // Try a lightweight request to verify the connection await authenticatedRequest("/tokens/keepAlive", "POST"); connectionVerified = true; return true; } catch (error) { logError(`Connection verification failed: ${getErrorMessage(error)}`); connectionVerified = false; return false; } }
  • Input schema for check-connection tool: empty object, indicating no input parameters are required.
    server.tool("check-connection", "Check if the current API URL and authentication are valid", {}, async () => {

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