mc8yp 1.0.0
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 +21 -0
- package/README.md +221 -0
- package/dist/add-BnID18hd.mjs +53 -0
- package/dist/cli.mjs +67621 -0
- package/dist/creds-D4yS306d.mjs +21 -0
- package/dist/list-qI93mmZ-.mjs +31 -0
- package/dist/remove-B-bSxaTt.mjs +51 -0
- package/package.json +70 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 schplitt
|
|
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,221 @@
|
|
|
1
|
+
# mc8yp - Cumulocity IoT MCP Server
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that provides AI agents with comprehensive access to Cumulocity IoT platform data. This enables AI-powered device management, data analysis, and operational insights through standardized tooling.
|
|
8
|
+
|
|
9
|
+
**Two Deployment Modes:**
|
|
10
|
+
|
|
11
|
+
- **CLI Mode**: Run locally with `pnpm dlx mc8yp` for development and testing with AI agents like Claude Desktop. Uses your system's secure keyring to store credentials.
|
|
12
|
+
- **Microservice Mode**: Deploy as a Cumulocity microservice for production use. The MCP endpoint (`/mcp`) integrates with Cumulocity's agents manager, using the service user's permissions automatically.
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### CLI Mode (Local Development & Testing)
|
|
17
|
+
|
|
18
|
+
The CLI mode allows you to run the MCP server locally and connect it to your AI agent (e.g., Claude Desktop). It uses STDIO transport and stores Cumulocity credentials securely in your system's native keyring.
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
# Run directly with pnpm (recommended)
|
|
22
|
+
pnpm dlx mc8yp
|
|
23
|
+
|
|
24
|
+
# Or install globally
|
|
25
|
+
npm install -g mc8yp
|
|
26
|
+
mc8yp
|
|
27
|
+
|
|
28
|
+
# Or with pnpm
|
|
29
|
+
pnpm add -g mc8yp
|
|
30
|
+
mc8yp
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**Credential Storage:**
|
|
34
|
+
Credentials are stored using your operating system's secure credential manager:
|
|
35
|
+
|
|
36
|
+
- **macOS**: Keychain
|
|
37
|
+
- **Windows**: Credential Vault
|
|
38
|
+
- **Linux**: Secret Service API (libsecret)
|
|
39
|
+
|
|
40
|
+
### Microservice Mode (Production Deployment)
|
|
41
|
+
|
|
42
|
+
The microservice mode is designed **exclusively for deployment on Cumulocity IoT**. The server exposes an HTTP endpoint at `/mcp` that integrates with Cumulocity's agents manager, automatically using the service user's credentials and permissions.
|
|
43
|
+
|
|
44
|
+
**Deployment Steps:**
|
|
45
|
+
|
|
46
|
+
1. Download the latest release package from [GitHub Releases](https://github.com/schplitt/mc8yp/releases)
|
|
47
|
+
2. Upload the `.zip` file to Cumulocity via **Application Management**
|
|
48
|
+
3. Subscribe to the application in your tenant
|
|
49
|
+
4. The MCP server will be available at: `https://<tenant>.cumulocity.com/service/mc8yp-server/mcp`
|
|
50
|
+
|
|
51
|
+
The microservice uses Cumulocity's built-in service user authentication - no additional credential configuration needed.
|
|
52
|
+
|
|
53
|
+
## Usage
|
|
54
|
+
|
|
55
|
+
### CLI Mode: Managing Credentials
|
|
56
|
+
|
|
57
|
+
Before using the CLI, you need to store your Cumulocity credentials securely:
|
|
58
|
+
|
|
59
|
+
```sh
|
|
60
|
+
# Add credentials (prompts for tenant URL, username, password)
|
|
61
|
+
pnpm dlx mc8yp creds add
|
|
62
|
+
|
|
63
|
+
# List stored credentials
|
|
64
|
+
pnpm dlx mc8yp creds list
|
|
65
|
+
|
|
66
|
+
# Remove credentials
|
|
67
|
+
pnpm dlx mc8yp creds remove
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The CLI stores credentials in your system's native credential manager and automatically uses them when you connect the MCP server to your AI agent. The `list-credentials` tool is also available within MCP sessions when running in CLI mode.
|
|
71
|
+
|
|
72
|
+
### Connecting to Local Agents
|
|
73
|
+
|
|
74
|
+
For local development with Claude Desktop or similar MCP clients, add to your MCP configuration:
|
|
75
|
+
|
|
76
|
+
```json
|
|
77
|
+
{
|
|
78
|
+
"servers": {
|
|
79
|
+
"mc8yp": {
|
|
80
|
+
"type": "stdio",
|
|
81
|
+
"command": "pnpm",
|
|
82
|
+
"args": ["dlx", "mc8yp"]
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The server will automatically use credentials stored in your system keyring.
|
|
89
|
+
|
|
90
|
+
## Development
|
|
91
|
+
|
|
92
|
+
### Prerequisites
|
|
93
|
+
|
|
94
|
+
- Node.js ≥22.0.0
|
|
95
|
+
- pnpm
|
|
96
|
+
- Access to a Cumulocity IoT tenant
|
|
97
|
+
|
|
98
|
+
### Setup
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
# Install dependencies
|
|
102
|
+
pnpm install
|
|
103
|
+
|
|
104
|
+
# Lint code
|
|
105
|
+
pnpm lint
|
|
106
|
+
|
|
107
|
+
# Type check
|
|
108
|
+
pnpm typecheck
|
|
109
|
+
|
|
110
|
+
# Build
|
|
111
|
+
pnpm build
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Run Locally
|
|
115
|
+
|
|
116
|
+
Add the mc8yp server to your local MCP client configuration (e.g., Claude Desktop) with the following command:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"servers": {
|
|
121
|
+
"local_mc8yp": {
|
|
122
|
+
"type": "stdio",
|
|
123
|
+
"command": "pnpm",
|
|
124
|
+
"args": [
|
|
125
|
+
"dlx",
|
|
126
|
+
"jiti",
|
|
127
|
+
"/path/to/your/project/src/cli/index.ts"
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
This allows you to test and develop the MCP server locally using your preferred MCP client.
|
|
135
|
+
|
|
136
|
+
## Available Tools & Prompts
|
|
137
|
+
|
|
138
|
+
### 🛠️ Tools (20 Total)
|
|
139
|
+
|
|
140
|
+
> **Note**: In CLI mode, an additional `list-credentials` tool is available to view stored credentials from your system keyring. This tool is not available in microservice deployments.
|
|
141
|
+
|
|
142
|
+
**Inventory Management** (4 tools)
|
|
143
|
+
|
|
144
|
+
- `query-inventory` - Query devices, groups, and assets using OData filters
|
|
145
|
+
- `get-object` - Get detailed device/group/asset information by ID
|
|
146
|
+
- `list-children` - List child objects in device hierarchy
|
|
147
|
+
- `get-supported-series` - Discover measurement types a device supports
|
|
148
|
+
|
|
149
|
+
**Measurements** (2 tools)
|
|
150
|
+
|
|
151
|
+
- `get-measurements` - Retrieve time-series measurement data
|
|
152
|
+
- `get-measurement-stats` - Get min/max/avg statistics for measurements
|
|
153
|
+
|
|
154
|
+
**Events** (2 tools)
|
|
155
|
+
|
|
156
|
+
- `get-events` - Query device events with filters
|
|
157
|
+
- `get-event-types` - Discover available event types for a device
|
|
158
|
+
|
|
159
|
+
**Alarms** (2 tools)
|
|
160
|
+
|
|
161
|
+
- `get-alarms` - Query alarms with filtering by severity, status, type
|
|
162
|
+
- `get-alarm-counts` - Get alarm counts grouped by severity
|
|
163
|
+
|
|
164
|
+
**Metadata & Administration** (10 tools)
|
|
165
|
+
|
|
166
|
+
- `get-current-tenant` - Get current tenant information
|
|
167
|
+
- `get-current-user` - Get current user details
|
|
168
|
+
- `get-users` - List users on the tenant
|
|
169
|
+
- `get-applications` - List available applications
|
|
170
|
+
- `get-application` - Get specific application details
|
|
171
|
+
- `get-application-versions` - Get all versions of an application
|
|
172
|
+
- `get-audit` - Query audit logs
|
|
173
|
+
- `get-tenant-stats` - Get tenant usage statistics
|
|
174
|
+
- `get-tenant-summary` - Get tenant usage summary
|
|
175
|
+
- `get-dashboards` - Get dashboards for a device or group
|
|
176
|
+
|
|
177
|
+
### 💬 Prompts (17 Total)
|
|
178
|
+
|
|
179
|
+
Pre-built prompt templates that guide AI agents through common IoT workflows:
|
|
180
|
+
|
|
181
|
+
**Date & Time** (2 prompts)
|
|
182
|
+
|
|
183
|
+
- Date/time range calculations
|
|
184
|
+
- Time window guidance for queries
|
|
185
|
+
|
|
186
|
+
**Inventory** (4 prompts)
|
|
187
|
+
|
|
188
|
+
- Device lookup and hierarchy navigation
|
|
189
|
+
- Finding devices by criteria
|
|
190
|
+
- OData query syntax help
|
|
191
|
+
- Device discovery workflows
|
|
192
|
+
|
|
193
|
+
**Measurements** (3 prompts)
|
|
194
|
+
|
|
195
|
+
- Measurement data analysis
|
|
196
|
+
- Time range calculations
|
|
197
|
+
- Data aggregation guidance
|
|
198
|
+
|
|
199
|
+
**Events** (2 prompts)
|
|
200
|
+
|
|
201
|
+
- Event type discovery
|
|
202
|
+
- Event history querying
|
|
203
|
+
|
|
204
|
+
**Alarms** (2 prompts)
|
|
205
|
+
|
|
206
|
+
- Alarm status interpretation
|
|
207
|
+
- Troubleshooting workflows
|
|
208
|
+
|
|
209
|
+
**Metadata** (1 prompt)
|
|
210
|
+
|
|
211
|
+
- Tenant context understanding
|
|
212
|
+
|
|
213
|
+
**Tenant & Administration** (3 prompts)
|
|
214
|
+
|
|
215
|
+
- Tenant configuration and settings
|
|
216
|
+
- Audit log querying
|
|
217
|
+
- Application management
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { i as setStoredC8yAuth, r as getStoredC8yAuth, t as cleanTenantUrl } from "./cli.mjs";
|
|
2
|
+
import { defineCommand } from "citty";
|
|
3
|
+
import consola from "consola";
|
|
4
|
+
import * as v from "valibot";
|
|
5
|
+
import { exit } from "node:process";
|
|
6
|
+
|
|
7
|
+
//#region src/cli/subcommands/subcommands/add.ts
|
|
8
|
+
const command = defineCommand({
|
|
9
|
+
meta: {
|
|
10
|
+
name: "add",
|
|
11
|
+
description: "Add new Cumulocity credentials"
|
|
12
|
+
},
|
|
13
|
+
run: async () => {
|
|
14
|
+
try {
|
|
15
|
+
const tenantUrl = await consola.prompt("Cumulocity tenant URL:", {
|
|
16
|
+
type: "text",
|
|
17
|
+
cancel: "reject"
|
|
18
|
+
});
|
|
19
|
+
v.parse(v.pipe(v.string(), v.url()), tenantUrl);
|
|
20
|
+
const user = await consola.prompt("Username:", {
|
|
21
|
+
type: "text",
|
|
22
|
+
cancel: "reject"
|
|
23
|
+
});
|
|
24
|
+
const password = await consola.prompt("Password:", {
|
|
25
|
+
type: "text",
|
|
26
|
+
cancel: "reject"
|
|
27
|
+
});
|
|
28
|
+
if ((await getStoredC8yAuth()).some((cred) => cred.tenantUrl === cleanTenantUrl(tenantUrl))) {
|
|
29
|
+
if (!await consola.prompt("Credentials for this tenant already exist. Overwrite?", {
|
|
30
|
+
type: "confirm",
|
|
31
|
+
cancel: "reject"
|
|
32
|
+
})) {
|
|
33
|
+
consola.info("Cancelled.");
|
|
34
|
+
exit();
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
await setStoredC8yAuth({
|
|
38
|
+
tenantUrl,
|
|
39
|
+
user,
|
|
40
|
+
password
|
|
41
|
+
});
|
|
42
|
+
consola.success("Credentials saved successfully!");
|
|
43
|
+
exit();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
consola.error("Failed to add credentials:", error);
|
|
46
|
+
exit();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
var add_default = command;
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
export { add_default as default };
|