Kubecost MCP Server

Kubecost MCP Server

An implementation that enables AI assistants to interact with Kubecost cost management platform through natural language, providing access to budget management and cost analysis features.

Category
访问服务器

README

Kubecost MCP Server

An implementation of Model Context Protocol (MCP) server for Kubecost, enabling AI assistants to interact with your Kubecost cost management platform through natural language. This server allows for seamless integration with Visual Studio Code, Cursor, and other MCP clients through stdio transport protocol.

Features

  • Transport Protocols: Supports stdio transport mode for flexible integration with different clients
  • Complete Kubecost API Integration: Provides comprehensive access to Kubecost resources and operations
  • Budget Management: Full CRUD operations for budget rules with notifications
  • Cost Analysis: Access to cost allocation and asset data
  • AI Assistant Ready: Pre-configured tools for AI assistants to interact with Kubecost in natural language

Installation

Prerequisites

  • Node.js (v18 or higher recommended)
  • pnpm package manager (for development)
  • Kubecost instance with API access
  • Kubecost API token or username/password

Usage with Cursor

  1. Follow the Cursor documentation for MCP support, and create a .cursor/mcp.json file in your project:
{
  "mcpServers": {
    "kubecost-mcp": {
      "command": "npx",
      "args": [
        "kubecost-mcp@latest",
        "stdio"
      ],
      "env": {
        "KUBECOST_BASE_URL": "<kubecost_url>",
        "KUBECOST_API_TOKEN": "<kubecost_token>"
      }
    }
  }
}
  1. Start a conversation with Agent mode to use the MCP.

Usage with VSCode

  1. Follow the Use MCP servers in VS Code documentation, and create a .vscode/mcp.json file in your project:
{
  "servers": {
    "kubecost-mcp-stdio": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "kubecost-mcp@latest",
        "stdio"
      ],
      "env": {
        "KUBECOST_BASE_URL": "<kubecost_url>",
        "KUBECOST_API_TOKEN": "<kubecost_token>"
      }
    }
  }
}
  1. Start a conversation with an AI assistant in VS Code that supports MCP.

Usage with Claude Desktop

  1. Follow the MCP in Claude Desktop documentation, and create a claude_desktop_config.json configuration file:
{
  "mcpServers": {
    "kubecost-mcp": {
      "command": "npx",
      "args": [
        "kubecost-mcp@latest",
        "stdio"
      ],
      "env": {
        "KUBECOST_BASE_URL": "<kubecost_url>",
        "KUBECOST_API_TOKEN": "<kubecost_token>"
      }
    }
  }
}
  1. Configure Claude Desktop to use this configuration file in settings.

Authentication Options

You can authenticate with Kubecost using either:

  1. API Token (recommended):

    export KUBECOST_API_TOKEN="your-api-token"
    
  2. Username/Password:

    export KUBECOST_USERNAME="your-username"
    export KUBECOST_PASSWORD="your-password"
    

Self-signed Certificates

If your Kubecost instance uses self-signed certificates or certificates from a private Certificate Authority (CA), you may need to add the following environment variable to your configuration:

"NODE_TLS_REJECT_UNAUTHORIZED": "0"

This disables TLS certificate validation for Node.js when connecting to Kubecost instances using self-signed certificates or certificates from private CAs that aren't trusted by your system's certificate store.

Warning: Disabling SSL verification reduces security. Use this setting only in development environments or when you understand the security implications.

Available Tools

The server provides the following Kubecost management tools:

Budget Management

  • list_budgets: List all budget rules
  • get_budget: Get detailed information about a specific budget rule
  • create_budget: Create a new budget rule
  • update_budget: Update an existing budget rule
  • delete_budget: Delete a budget rule

Cost Analysis

  • get_cost_allocation: Get cost allocation data with filtering and aggregation
  • get_assets: Get asset data with filtering and aggregation
  • health_check: Check if Kubecost API is healthy and accessible

Budget API Examples

Create a Weekly Budget

Create a budget that resets every Wednesday with a budget of $100.00 USD, and will send an alert via email when spending has exceeded 75% of the spend limit:

{
  "name": "budget-rule",
  "values": {
    "cluster": ["test"]
  },
  "kind": "soft",
  "interval": "weekly",
  "intervalDay": 3,
  "spendLimit": 100,
  "actions": [
    {
      "percentage": 75,
      "emails": [
        "admin@company.com"
      ]
    }
  ]
}

Create a Monthly Budget

Create a budget for the kubecost namespace which resets on the 1st of every month with a budget of $400.00 USD, and will send alerts via Slack and Microsoft Teams when spending has exceeded $100.00 of the spend limit:

{
  "name": "budget-rule-2",
  "values": {
    "namespace": ["kubecost"]
  },
  "kind": "soft",
  "interval": "monthly",
  "intervalDay": 1,
  "spendLimit": 400,
  "actions": [
    {
      "percentage": 25,
      "slackWebhooks": [
        "<example Slack webhook>"
      ],
      "msTeamsWebhooks": [
        "<example Teams webhook>"
      ]
    }
  ]
}

For Development

  1. Clone the repository:
git clone https://github.com/your-username/kubecost-mcp.git
cd kubecost-mcp
  1. Install project dependencies:
pnpm install
  1. Start the development server with hot reloading enabled:
pnpm run dev

Once the server is running, you can utilize the MCP server within Visual Studio Code or other MCP client.

Environment Variables

Variable Required Description
KUBECOST_BASE_URL Yes The base URL of your Kubecost instance
KUBECOST_API_TOKEN No* API token for authentication
KUBECOST_USERNAME No* Username for basic authentication
KUBECOST_PASSWORD No* Password for basic authentication

*Either API token or username/password combination is required.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

MIT License

About

This project provides a Model Context Protocol (MCP) server for Kubecost, enabling AI assistants to interact with cost management data through natural language.

Topics

kubernetes devops ai cost-management mcp kubecost model-context-protocol mcp-server budget-api cost-analysis

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选