home / mcp / pi api mcp server

PI API MCP Server

Provides standardized tools to interact with the PI Dashboard API, including authentication, categories, and charts management via MCP clients.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "mingzilla-pi-api-mcp-server": {
      "url": "http://localhost:8224/pi/api/v2",
      "headers": {
        "API_URL": "http://localhost:8224/pi/api/v2",
        "PI_API_KEY": "XXXXXXXX"
      }
    }
  }
}

You have a Model Context Protocol (MCP) server that provides standardized tools and resources to securely interact with the PI Dashboard API. This server enables Claude and other MCP-compatible assistants to access PI Dashboard resources such as categories and charts, perform authentication, manage data, and export chart data for analysis.

How to use

After you have the MCP server running, you can connect from an MCP client and perform common actions like authenticating, listing categories and charts, and exporting chart data for analysis. Start by configuring the base API URL, authenticate, check the connection, and then explore the available resources.

Typical workflow you will follow in day-to-day use: set the API URL, authenticate, verify the connection, list charts, view or export chart data, and run analysis prompts to gain insights from the dashboard.

If you need to analyze a chart or extract metadata, you can retrieve metadata from a specific chart, identify related chart IDs, obtain their JSON data, and analyze the results to generate actionable insights.

How to install

Prerequisites you should have before installing include Node.js and npm, or Docker if you prefer containerized execution.

Install via Smithery for automatic client integration with your MCP setup.

npx -y @smithery/cli install @mingzilla/pi-api-mcp-server --client claude

Installation via Docker (recommended)

Use Docker to run the MCP server without additional MCP configuration. You will provide environment variables for the API URL and API key.

Create or update your MCP client configuration to include the Docker-based server so that your client can connect and issue commands.

{
  "mcpServers": {
    "pi-api": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "API_URL=http://localhost:8224/pi/api/v2",
        "-e",
        "PI_API_KEY=XXXXXXXX",
        "mingzilla/pi-api-mcp-server"
      ],
      "disabled": false,
      "autoApprove": [
        "keep-session-alive",
        "check-connection",
        "authenticate",
        "list-categories",
        "get-category",
        "list-charts", 
        "get-chart",
        "export-chart",
        "get-filterable-attributes",
        "export-chart"
      ]
    }
  }
}

Configuration and environment

You will configure the MCP client with the base API URL and credentials for API access. If the API URL is not provided at initialization, you will be prompted to set it before performing any operations.

Environment variables used by the Docker-based server are shown in the example and should be provided in your environment or MCP client configuration.

Notes and usage tips

- Use the provided tools to manage categories and charts, extract filterable attributes, and export charts for external use.

- Ensure authentication tokens are kept secure and rotate tokens as needed. Use the keep-session-alive tool to refresh tokens when using token-based authentication.

Available tools

authenticate

Obtain guidance on authenticating with the PI API and establishing a session

authenticate-with-credentials

Authenticate using a username and password as a last-resort option

keep-session-alive

Verify and refresh the current authentication token to maintain an active session

logout

Invalidate the current token and end the session

set-api-url

Configure the base API URL used for all requests by the MCP client

set-organization

Set the organization ID for subsequent requests

check-connection

Validate the API URL and authentication status to ensure connectivity

list-categories

Retrieve all categories with optional filtering options

get-category

Retrieve a specific category by its ID

create-category

Create a new category in the PI Dashboard

update-category

Update an existing category by its ID

delete-category

Delete a category by its ID

list-category-objects

List all objects within a specific category

list-charts

List all charts with optional filtering options

get-chart

Retrieve a specific chart by its ID

delete-chart

Delete a chart by its ID

export-chart

Export a chart in various formats