castai-mcp-server 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 CAST.AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,266 @@
1
+ # CAST.AI MCP Server
2
+
3
+ Model Context Protocol (MCP) server for the CAST.AI API. This server enables Claude Desktop and other MCP clients to interact with your CAST.AI Kubernetes clusters through natural language.
4
+
5
+ ## Features
6
+
7
+ - **5 Cluster Management Tools**:
8
+ - `list_clusters` - List all your Kubernetes clusters
9
+ - `get_cluster_details` - Get detailed information about a specific cluster
10
+ - `get_cluster_policies` - View cluster policies and configuration
11
+ - `get_cluster_score` - Get cluster optimization score
12
+ - `get_cluster_score_history` - View historical cluster score data
13
+
14
+ - **Simple Authentication**: API key-based authentication (no OAuth complexity)
15
+ - **Local Only**: Works with Claude Desktop via stdio transport
16
+ - **Cluster Name Resolution**: Use either cluster UUID or friendly cluster name
17
+
18
+ ## Prerequisites
19
+
20
+ - **For npx installation (recommended)**: Node.js 16+ and [uv](https://docs.astral.sh/uv/)
21
+ - **For uvx installation**: [uv](https://docs.astral.sh/uv/) only
22
+ - **For local development**: Python 3.11+ and [uv](https://docs.astral.sh/uv/)
23
+ - **Always required**: CAST.AI account with API access
24
+
25
+ ## Installation
26
+
27
+ ### Quick Start (Recommended) ⭐
28
+
29
+ The easiest way to use CAST.AI MCP Server - no installation or cloning required!
30
+
31
+ **1. Get your CAST.AI API key**:
32
+ - Visit [console.cast.ai](https://console.cast.ai)
33
+ - Navigate to **Settings** > **API Keys**
34
+ - Click **Create API Key**
35
+ - Choose **Read-only** access (recommended) or **Full access**
36
+ - Copy the generated API key
37
+
38
+ **2. Configure Claude Desktop**:
39
+
40
+ Edit your Claude Desktop configuration file:
41
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
42
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
43
+
44
+ Add this configuration:
45
+
46
+ ```json
47
+ {
48
+ "mcpServers": {
49
+ "castai": {
50
+ "command": "npx",
51
+ "args": ["-y", "castai-mcp-server@latest"],
52
+ "env": {
53
+ "CASTAI_API_KEY": "your-api-key-here"
54
+ }
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ **3. Restart Claude Desktop**
61
+
62
+ That's it! The server will be automatically downloaded and run when needed.
63
+
64
+ ---
65
+
66
+ ### Alternative Installation Methods
67
+
68
+ <details>
69
+ <summary><b>Using uvx</b> (Python package manager)</summary>
70
+
71
+ Requires: [uv](https://docs.astral.sh/uv/) installed
72
+
73
+ ```json
74
+ {
75
+ "mcpServers": {
76
+ "castai": {
77
+ "command": "uvx",
78
+ "args": ["castai-mcp-server"],
79
+ "env": {
80
+ "CASTAI_API_KEY": "your-api-key-here"
81
+ }
82
+ }
83
+ }
84
+ }
85
+ ```
86
+
87
+ Restart Claude Desktop.
88
+ </details>
89
+
90
+ <details>
91
+ <summary><b>Development / Local Installation</b></summary>
92
+
93
+ For local development or if you want to modify the code:
94
+
95
+ 1. **Clone the repository**:
96
+ ```bash
97
+ cd ~/repos
98
+ git clone https://github.com/castai/castai-mcp-external.git
99
+ cd castai-mcp-external
100
+ ```
101
+
102
+ 2. **Install dependencies**:
103
+ ```bash
104
+ uv sync
105
+ ```
106
+
107
+ 3. **Configure Claude Desktop**:
108
+ ```json
109
+ {
110
+ "mcpServers": {
111
+ "castai": {
112
+ "command": "uv",
113
+ "args": [
114
+ "--directory",
115
+ "/ABSOLUTE/PATH/TO/castai-mcp-external",
116
+ "run",
117
+ "python",
118
+ "main.py"
119
+ ],
120
+ "env": {
121
+ "CASTAI_API_KEY": "your-api-key-here"
122
+ }
123
+ }
124
+ }
125
+ }
126
+ ```
127
+
128
+ **Important**: Replace `/ABSOLUTE/PATH/TO/castai-mcp-external` with the actual absolute path.
129
+
130
+ 4. **Restart Claude Desktop**
131
+ </details>
132
+
133
+ ## Usage Examples
134
+
135
+ Once configured, you can interact with your CAST.AI clusters using natural language in Claude Desktop:
136
+
137
+ ### List all clusters
138
+ ```
139
+ Show me all my Kubernetes clusters
140
+ ```
141
+
142
+ ### Get cluster details
143
+ ```
144
+ Get details for cluster "production-gke"
145
+ ```
146
+ or
147
+ ```
148
+ Show me information about cluster a1b2c3d4-e5f6-7890-abcd-ef1234567890
149
+ ```
150
+
151
+ ### View cluster policies
152
+ ```
153
+ What are the policies configured for my staging cluster?
154
+ ```
155
+
156
+ ### Check cluster optimization score
157
+ ```
158
+ What's the optimization score for my production cluster?
159
+ ```
160
+
161
+ ### View score history
162
+ ```
163
+ Show me the historical cluster score for my main cluster
164
+ ```
165
+
166
+ ## Configuration
167
+
168
+ ### Environment Variables
169
+
170
+ - `CASTAI_API_KEY` (required) - Your CAST.AI API key from console.cast.ai
171
+ - `CASTAI_API_URL` (optional) - API endpoint URL (defaults to `https://api.cast.ai`)
172
+
173
+ ### Using a Different API Endpoint
174
+
175
+ If you're using a non-production CAST.AI environment, you can override the API URL:
176
+
177
+ ```json
178
+ {
179
+ "mcpServers": {
180
+ "castai": {
181
+ "command": "uv",
182
+ "args": ["--directory", "/path/to/castai-mcp-external", "run", "python", "main.py"],
183
+ "env": {
184
+ "CASTAI_API_KEY": "your-api-key-here",
185
+ "CASTAI_API_URL": "https://api.dev-master.cast.ai"
186
+ }
187
+ }
188
+ }
189
+ }
190
+ ```
191
+
192
+ ## Troubleshooting
193
+
194
+ ### Authentication Errors
195
+
196
+ If you see a 401 authentication error:
197
+ 1. Verify your API key is correct in `claude_desktop_config.json`
198
+ 2. Check that the API key hasn't expired in the CAST.AI console
199
+ 3. Ensure the API key has the necessary permissions
200
+ 4. Restart Claude Desktop after making changes
201
+
202
+ ### Cluster Not Found
203
+
204
+ If you get a "Cluster not found" error:
205
+ - Verify you're using the exact cluster name as shown in CAST.AI console
206
+ - Alternatively, use the cluster UUID instead of the name
207
+ - Check that your API key has access to the cluster's organization
208
+
209
+ ### Server Not Starting
210
+
211
+ If the MCP server doesn't appear in Claude Desktop:
212
+ 1. Check the Claude Desktop logs:
213
+ - **macOS**: `~/Library/Logs/Claude/mcp*.log`
214
+ - **Windows**: `%APPDATA%\Claude\Logs\mcp*.log`
215
+ 2. Verify the absolute path to `castai-mcp-external` is correct
216
+ 3. Ensure `uv` is installed and in your PATH
217
+ 4. Test the server manually:
218
+ ```bash
219
+ cd /path/to/castai-mcp-external
220
+ export CASTAI_API_KEY="your-key"
221
+ uv run python main.py
222
+ ```
223
+
224
+ ### View Server Logs
225
+
226
+ To see detailed logs from the MCP server:
227
+ ```bash
228
+ cd /path/to/castai-mcp-external
229
+ export CASTAI_API_KEY="your-key"
230
+ uv run python main.py
231
+ ```
232
+
233
+ The server will output structured logs in logfmt format to stderr.
234
+
235
+ ## Security Best Practices
236
+
237
+ 1. **Use Read-Only API Keys**: For safety, create API keys with read-only access unless you specifically need write permissions
238
+ 2. **Rotate API Keys Regularly**: Periodically generate new API keys and update your configuration
239
+ 3. **Protect Your API Key**: Never commit API keys to version control or share them publicly
240
+ 4. **Use Environment Variables**: Always configure API keys via environment variables, not hardcoded in files
241
+
242
+ ## API Endpoints Used
243
+
244
+ This MCP server uses the following CAST.AI API endpoints:
245
+
246
+ - `GET /v1/kubernetes/external-clusters` - List clusters
247
+ - `GET /v1/kubernetes/external-clusters/{id}` - Get cluster details
248
+ - `GET /v1/kubernetes/clusters/{id}/policies` - Get cluster policies
249
+ - `GET /v1/cost-reports/clusters/{id}/cluster-score` - Get cluster score
250
+ - `GET /v1/cost-reports/clusters/{id}/cluster-score-history` - Get score history
251
+
252
+ ## Documentation
253
+
254
+ - [CAST.AI API Documentation](https://api.cast.ai/v1/spec/#/)
255
+ - [Model Context Protocol Documentation](https://modelcontextprotocol.io/)
256
+ - [Claude Desktop Documentation](https://claude.ai/docs)
257
+
258
+ ## Support
259
+
260
+ For issues or questions:
261
+ - CAST.AI API Issues: [support@cast.ai](mailto:support@cast.ai)
262
+ - MCP Server Issues: [GitHub Issues](https://github.com/castai/castai-mcp-external/issues)
263
+
264
+ ## License
265
+
266
+ MIT License - see [LICENSE](LICENSE) file for details.
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const { execSync } = require('child_process');
5
+ const os = require('os');
6
+
7
+ // Determine uvx command based on platform
8
+ const isWindows = os.platform() === 'win32';
9
+ const uvxCommand = isWindows ? 'uvx.exe' : 'uvx';
10
+
11
+ // Check if uv is installed
12
+ function checkUvInstalled() {
13
+ try {
14
+ execSync(isWindows ? 'where uvx' : 'which uvx', { stdio: 'ignore' });
15
+ return true;
16
+ } catch (error) {
17
+ return false;
18
+ }
19
+ }
20
+
21
+ if (!checkUvInstalled()) {
22
+ console.error('Error: uv is not installed.');
23
+ console.error('');
24
+ console.error('CAST.AI MCP Server requires uv to be installed.');
25
+ console.error('');
26
+ console.error('Install uv:');
27
+ console.error(' macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh');
28
+ console.error(' Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"');
29
+ console.error(' Or visit: https://docs.astral.sh/uv/getting-started/installation/');
30
+ console.error('');
31
+ process.exit(1);
32
+ }
33
+
34
+ // Run the Python package via uvx
35
+ const args = ['castai-mcp-server'];
36
+
37
+ // Forward all command line arguments
38
+ if (process.argv.length > 2) {
39
+ args.push(...process.argv.slice(2));
40
+ }
41
+
42
+ const child = spawn(uvxCommand, args, {
43
+ stdio: 'inherit',
44
+ env: process.env,
45
+ shell: isWindows
46
+ });
47
+
48
+ child.on('error', (error) => {
49
+ console.error(`Failed to start castai-mcp-server: ${error.message}`);
50
+ process.exit(1);
51
+ });
52
+
53
+ child.on('exit', (code, signal) => {
54
+ if (signal) {
55
+ process.kill(process.pid, signal);
56
+ } else {
57
+ process.exit(code || 0);
58
+ }
59
+ });
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "castai-mcp-server",
3
+ "version": "0.2.1",
4
+ "description": "Model Context Protocol server for CAST.AI - manage Kubernetes clusters via natural language",
5
+ "bin": {
6
+ "castai-mcp-server": "./bin/castai-mcp-server.js"
7
+ },
8
+ "scripts": {
9
+ "test": "node bin/castai-mcp-server.js --help || true"
10
+ },
11
+ "keywords": [
12
+ "mcp",
13
+ "model-context-protocol",
14
+ "castai",
15
+ "kubernetes",
16
+ "llm",
17
+ "claude",
18
+ "ai"
19
+ ],
20
+ "author": "CAST.AI <support@cast.ai>",
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/castai/castai-mcp-external.git"
25
+ },
26
+ "homepage": "https://github.com/castai/castai-mcp-external#readme",
27
+ "bugs": {
28
+ "url": "https://github.com/castai/castai-mcp-external/issues"
29
+ },
30
+ "files": [
31
+ "bin/",
32
+ "README.md",
33
+ "LICENSE"
34
+ ],
35
+ "engines": {
36
+ "node": ">=16.0.0"
37
+ },
38
+ "os": [
39
+ "darwin",
40
+ "linux",
41
+ "win32"
42
+ ]
43
+ }