@cplace/test-mcp-server 0.1.10 → 0.1.12
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/README.md +132 -29
- package/dist/api.d.ts +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js.map +1 -1
- package/dist/conditional-registration.d.ts +4 -0
- package/dist/conditional-registration.d.ts.map +1 -0
- package/dist/conditional-registration.js +40 -0
- package/dist/conditional-registration.js.map +1 -0
- package/dist/index.js +257 -27
- package/dist/index.js.map +1 -1
- package/dist/profiles.d.ts +10 -0
- package/dist/profiles.d.ts.map +1 -0
- package/dist/profiles.js +138 -0
- package/dist/profiles.js.map +1 -0
- package/dist/searchSchema.d.ts +44 -44
- package/dist/tools/change-listeners.d.ts +4 -0
- package/dist/tools/change-listeners.d.ts.map +1 -0
- package/dist/tools/change-listeners.js +101 -0
- package/dist/tools/change-listeners.js.map +1 -0
- package/dist/tools/pages.d.ts.map +1 -1
- package/dist/tools/pages.js +90 -4
- package/dist/tools/pages.js.map +1 -1
- package/dist/tools/ppt-export-profiles.d.ts +4 -0
- package/dist/tools/ppt-export-profiles.d.ts.map +1 -0
- package/dist/tools/ppt-export-profiles.js +245 -0
- package/dist/tools/ppt-export-profiles.js.map +1 -0
- package/dist/tools/references.d.ts.map +1 -1
- package/dist/tools/references.js +4 -2
- package/dist/tools/references.js.map +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +9 -5
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/type-layouts.d.ts.map +1 -1
- package/dist/tools/type-layouts.js +4 -2
- package/dist/tools/type-layouts.js.map +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +6 -3
- package/dist/tools/users.js.map +1 -1
- package/dist/tools/validators.d.ts +4 -0
- package/dist/tools/validators.d.ts.map +1 -0
- package/dist/tools/validators.js +90 -0
- package/dist/tools/validators.js.map +1 -0
- package/dist/tools/version-history.d.ts.map +1 -1
- package/dist/tools/version-history.js +8 -4
- package/dist/tools/version-history.js.map +1 -1
- package/dist/tools/widgets.d.ts.map +1 -1
- package/dist/tools/widgets.js +41 -13
- package/dist/tools/widgets.js.map +1 -1
- package/dist/tools/workspace.d.ts.map +1 -1
- package/dist/tools/workspace.js +324 -9
- package/dist/tools/workspace.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +24 -0
- package/dist/utils.js.map +1 -1
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
# @cplace/mcp-server
|
|
2
2
|
|
|
3
|
-
An MCP (Model Context Protocol) server that provides Claude Desktop with tools to interact with cplace APIs. This server exposes cplace functionality through a comprehensive set of
|
|
3
|
+
An MCP (Model Context Protocol) server that provides Claude Desktop and Claude Code with tools to interact with cplace APIs. This server exposes cplace functionality through a comprehensive set of MCP tools for workspace management, page operations, search capabilities, layout management, type definitions, automation scripts, and version history tracking.
|
|
4
|
+
|
|
5
|
+
The server supports a profile-based tool loading system to optimize LLM context usage by only loading the tools you need.
|
|
4
6
|
|
|
5
7
|
## Installation & Setup
|
|
6
8
|
|
|
9
|
+
> **⚠️ Important**: The `CPLACE_URL` must end with a forward slash (`/`) when working with a tenant. Missing this slash will result in 404 errors.
|
|
10
|
+
>
|
|
11
|
+
> ✅ Correct: `https://your-cplace-instance.com/your-tenant/`
|
|
12
|
+
> ❌ Incorrect: `https://your-cplace-instance.com/your-tenant`
|
|
13
|
+
|
|
7
14
|
### Claude Desktop Installation
|
|
8
|
-
|
|
15
|
+
|
|
16
|
+
#### Basic Setup (All tools)
|
|
17
|
+
By default, all tools are loaded. Add this entry to your Claude Desktop MCP server configuration file:
|
|
9
18
|
|
|
10
19
|
```json
|
|
11
20
|
{
|
|
@@ -22,9 +31,27 @@ Add this entry to your Claude Desktop MCP server configuration file:
|
|
|
22
31
|
}
|
|
23
32
|
```
|
|
24
33
|
|
|
34
|
+
#### With Profile Selection (Recommended for reduced token usage)
|
|
35
|
+
To load only specific tool groups and reduce LLM context usage, add the `--profiles` argument:
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"mcpServers": {
|
|
40
|
+
"cplace": {
|
|
41
|
+
"command": "npx",
|
|
42
|
+
"args": ["@cplace/test-mcp-server", "--profiles=layouts"],
|
|
43
|
+
"env": {
|
|
44
|
+
"CPLACE_URL": "https://your-cplace-instance.com/your-tenant/",
|
|
45
|
+
"API_TOKEN": "your-api-token"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
25
52
|
### Claude Code Installation
|
|
26
|
-
Use the Claude Code CLI to add the MCP server:
|
|
27
53
|
|
|
54
|
+
#### All tools (default):
|
|
28
55
|
```bash
|
|
29
56
|
claude mcp add cplace \
|
|
30
57
|
--env CPLACE_URL=https://your-cplace-instance.com/your-tenant/ \
|
|
@@ -32,6 +59,14 @@ claude mcp add cplace \
|
|
|
32
59
|
-- npx -y @cplace/test-mcp-server
|
|
33
60
|
```
|
|
34
61
|
|
|
62
|
+
#### With specific profiles (recommended):
|
|
63
|
+
```bash
|
|
64
|
+
claude mcp add cplace \
|
|
65
|
+
--env CPLACE_URL=https://your-cplace-instance.com/your-tenant/ \
|
|
66
|
+
--env API_TOKEN=your-api-token \
|
|
67
|
+
-- npx -y @cplace/test-mcp-server --profiles=layouts
|
|
68
|
+
```
|
|
69
|
+
|
|
35
70
|
Verify the installation:
|
|
36
71
|
```bash
|
|
37
72
|
claude mcp list
|
|
@@ -43,6 +78,13 @@ The `cplace-citizen-ai` repository must be part of the deployment. These plugins
|
|
|
43
78
|
* `cf.cplace.citizenAi`
|
|
44
79
|
* `cf.cplace.apiToken` - required for authentication
|
|
45
80
|
|
|
81
|
+
### Additional Configuration Properties
|
|
82
|
+
|
|
83
|
+
The following configuration properties must be set for API Token authentication to work:
|
|
84
|
+
|
|
85
|
+
* `cplace.plugins.cf.cplace.apiToken.enable=true` - Hidden property that actually enables API Token authentication (not documented in ops configuration reference, see [issue #750](https://github.com/collaborationFactory/cplace/issues/750))
|
|
86
|
+
* `cplace.plugins.cf.cplace.apiToken.headerName=X-Cplace-Api-Token` - HTTP header name for the API token (default value, should not be changed)
|
|
87
|
+
|
|
46
88
|
## Usage
|
|
47
89
|
|
|
48
90
|
1. Obtain an API Token for your cplace system (see [cplace documentation](https://docs.cplace.io/lowcode/low-code-cli/authentication/))
|
|
@@ -59,67 +101,128 @@ The `cplace-citizen-ai` repository must be part of the deployment. These plugins
|
|
|
59
101
|
|
|
60
102
|
To change `CPLACE_URL` or `API_TOKEN`, update the values in the Claude Desktop configuration, then close & reopen Claude Desktop.
|
|
61
103
|
|
|
104
|
+
## Profile System
|
|
105
|
+
|
|
106
|
+
The server uses a profile-based tool loading system to optimize LLM context usage. By default, **all tools are loaded** if no profiles are specified. You can restrict to specific tool groups to reduce LLM context usage.
|
|
107
|
+
|
|
108
|
+
### Available Tool Groups
|
|
109
|
+
|
|
110
|
+
| Group | Description | Tools |
|
|
111
|
+
|-------|-------------|-------|
|
|
112
|
+
| **core** | Essential operations | Workspace navigation, page CRUD, search, users, references |
|
|
113
|
+
| **history** | Version history | Track changes and view page history |
|
|
114
|
+
| **layouts** | Widget and layout management | Full dashboard and widget management |
|
|
115
|
+
| **types_write** | Type and attribute management | Create and modify type definitions |
|
|
116
|
+
| **low_code** | Validators and change listeners | Automation scripts and validation |
|
|
117
|
+
| **ppt_export** | PowerPoint export | Create PowerPoint export profiles |
|
|
118
|
+
| **csv_export** | CSV export functionality | Export search results to CSV |
|
|
119
|
+
|
|
120
|
+
### Profile Usage Examples
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# All tools (default - no profiles specified)
|
|
124
|
+
npx @cplace/test-mcp-server
|
|
125
|
+
|
|
126
|
+
# Just core functionality
|
|
127
|
+
npx @cplace/test-mcp-server --profiles=core
|
|
128
|
+
|
|
129
|
+
# Dashboard development (core + layouts)
|
|
130
|
+
npx @cplace/test-mcp-server --profiles=layouts
|
|
62
131
|
|
|
132
|
+
# Type development (core + types_write + low_code)
|
|
133
|
+
npx @cplace/test-mcp-server --profiles=types_write+low_code
|
|
134
|
+
|
|
135
|
+
# Data analysis (core + csv_export + history)
|
|
136
|
+
npx @cplace/test-mcp-server --profiles=csv_export+history
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Checking Active Profiles
|
|
140
|
+
|
|
141
|
+
Use the `cplace_profile_info` tool in Claude to see which profiles are currently active and what tools are available.
|
|
63
142
|
|
|
64
143
|
## Available Tools
|
|
65
144
|
|
|
66
|
-
###
|
|
145
|
+
### Core (Always Loaded)
|
|
146
|
+
Essential operations including workspace navigation, page CRUD operations, search, users, and references.
|
|
147
|
+
|
|
67
148
|
- `cplace_list_workspaces` - Get all workspaces with essential properties
|
|
68
149
|
- `cplace_get_workspace_details` - Get comprehensive details about a specific workspace including all metadata, permissions, type definitions, styling, and configuration
|
|
69
150
|
- `cplace_list_types` - List all types available in a workspace
|
|
70
151
|
- `cplace_get_type_datamodel` - Get the datamodel of a type including its attributes, constraints, and permissions
|
|
71
|
-
|
|
72
|
-
### Page Operations
|
|
73
152
|
- `cplace_get_page_by_id` - Get page by ID with full details
|
|
74
153
|
- `cplace_create_page` - Create a new page with specified attributes and content
|
|
75
154
|
- `cplace_update_page` - Update an existing page's attributes, content, or structure
|
|
76
155
|
- `cplace_update_page_attributes` - Lightweight tool for updating only page attributes
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
- `cplace_search_pages` - Search pages of a type in cplace
|
|
156
|
+
- `cplace_delete_page` - Permanently delete a single page (leaf pages only)
|
|
157
|
+
- `cplace_delete_page_with_children` - Permanently delete a page and optionally all its children
|
|
158
|
+
- `cplace_search_pages` - Search pages of a type in cplace with advanced filtering
|
|
80
159
|
- `cplace_search_pages_fulltext` - Make a fulltext search across all pages in cplace
|
|
81
160
|
- `cplace_list_pages_of_type` - List all pages of a specific type in a workspace
|
|
82
|
-
- `cplace_search_pages_csv` - Same as cplace_search_pages but returns results in CSV format
|
|
83
|
-
|
|
84
|
-
### User & Person Management
|
|
85
161
|
- `cplace_get_person_by_id` - Get details about a person including their name and email
|
|
86
162
|
- `cplace_get_person_by_name` - Get details about a person by searching for their name
|
|
87
163
|
- `cplace_get_current_user` - Get information about the currently logged-in user
|
|
88
|
-
|
|
89
|
-
### Reference Management
|
|
90
164
|
- `cplace_get_type_incoming_references` - Get comprehensive information about all incoming references to a specific type definition
|
|
91
165
|
- `cplace_get_page_incoming_references` - Get comprehensive information about all incoming references to a specific page
|
|
166
|
+
- `cplace_profile_info` - Get information about active MCP profiles and available groups
|
|
92
167
|
|
|
93
|
-
###
|
|
94
|
-
|
|
95
|
-
- `cplace_get_page_state_at_timestamp` - Reconstruct and return the complete state of a page as it was at a specific point in time
|
|
96
|
-
- `cplace_get_page_diff` - Compare page states between two timestamps and return the differences
|
|
97
|
-
- `cplace_get_page_changesets_summary` - Get a summary of recent changes for a page (convenience tool for last 7 days by default)
|
|
98
|
-
|
|
99
|
-
### Widget & Layout Management
|
|
168
|
+
### Layouts (Profile: layouts)
|
|
169
|
+
Widget and dashboard layout management.
|
|
100
170
|
|
|
101
|
-
#### Widget Definitions & Discovery
|
|
102
171
|
- `cplace_list_widget_definitions` - Get a list of all available widget definitions with their metadata
|
|
103
172
|
- `cplace_get_widget_definition` - Get detailed information about a specific widget definition including its configuration schema
|
|
104
|
-
|
|
105
|
-
#### Page Layout Operations
|
|
106
173
|
- `cplace_get_page_layout_overview` - Get the high-level layout structure of a page including rows, columns, and widget summaries
|
|
107
174
|
- `cplace_get_widget_details` - Get detailed configuration for a specific widget within a page layout
|
|
108
175
|
- `cplace_add_widget_to_layout` - Add a new widget to a page layout at a specific position
|
|
109
176
|
- `cplace_remove_widget_from_layout` - Remove an existing widget from a page layout
|
|
110
177
|
- `cplace_update_widget_in_layout` - Modify widget configuration or display properties
|
|
111
178
|
- `cplace_move_widget_in_layout` - Relocate a widget to a different position in the layout
|
|
112
|
-
- `cplace_compact_page_layout` - Remove all empty rows from a page layout, compacting it by keeping only rows with widgets
|
|
113
|
-
|
|
114
|
-
#### Embedded Layout Operations
|
|
115
179
|
- `cplace_get_embedded_layout` - Get the widget layout structure of an embedded widget within a container widget
|
|
116
180
|
- `cplace_add_widget_to_embedded_layout` - Add a new widget to an embedded layout within a container widget
|
|
117
181
|
- `cplace_remove_widget_from_embedded_layout` - Remove an existing widget from an embedded layout within a container widget
|
|
118
|
-
|
|
119
|
-
|
|
182
|
+
- `cplace_compact_page_layout` - Remove all empty rows from a page layout, compacting it by keeping only rows with widgets
|
|
183
|
+
- `cplace_add_row_to_page_layout` - Create a new row with specific column layout in a page layout
|
|
120
184
|
- `cplace_get_type_layout` - Get widget layout structure of a specific type definition (default or alternative layout)
|
|
121
185
|
- `cplace_list_type_alternative_layouts` - List all available layouts for a type with usage statistics (default + alternatives)
|
|
122
186
|
|
|
187
|
+
### Types Write (Profile: types_write)
|
|
188
|
+
Type and attribute creation and updates.
|
|
189
|
+
|
|
190
|
+
- `cplace_manage_type_definition` - Create or update type definitions in a workspace with comprehensive configuration options
|
|
191
|
+
- `cplace_manage_attribute_definition` - Create or update attribute definitions within existing type definitions
|
|
192
|
+
|
|
193
|
+
### Low-Code (Profile: low_code)
|
|
194
|
+
Validators and change listeners.
|
|
195
|
+
|
|
196
|
+
- `cplace_get_validator_by_attribute` - Get JavaScript validator script and metadata for a specific attribute
|
|
197
|
+
- `cplace_manage_validator` - Create or update JavaScript validators for attribute definitions
|
|
198
|
+
- `cplace_get_change_listeners_by_type` - Get all JavaScript automation scripts (change listeners) for a type
|
|
199
|
+
- `cplace_manage_change_listener` - Create or update JavaScript automation scripts that execute when specified attributes change
|
|
200
|
+
|
|
201
|
+
### PPT Export (Profile: ppt_export)
|
|
202
|
+
PowerPoint export profiles.
|
|
203
|
+
|
|
204
|
+
- `cplace_manage_ppt_export_profile` - Create or update PowerPoint Export Profiles with comprehensive configuration for page layout, timeline settings, task classes, and visual formatting
|
|
205
|
+
|
|
206
|
+
### History (Profile: history)
|
|
207
|
+
Version history and change tracking.
|
|
208
|
+
|
|
209
|
+
- `cplace_get_page_changesets` - Get all changesets (modification records) for a specific page within an optional time range
|
|
210
|
+
- `cplace_get_page_state_at_timestamp` - Reconstruct and return the complete state of a page as it was at a specific point in time
|
|
211
|
+
- `cplace_get_page_diff` - Compare page states between two timestamps and return the differences
|
|
212
|
+
- `cplace_get_page_changesets_summary` - Get a summary of recent changes for a page (convenience tool for last 7 days by default)
|
|
213
|
+
|
|
214
|
+
### CSV Export (Profile: csv_export)
|
|
215
|
+
CSV export functionality for search results.
|
|
216
|
+
|
|
217
|
+
- `cplace_search_pages_csv` - Export search results to CSV format
|
|
218
|
+
|
|
123
219
|
## Development
|
|
124
220
|
|
|
125
221
|
For development setup, contribution guidelines, and extending the server, see [DEVELOPMENT.md](DEVELOPMENT.md).
|
|
222
|
+
|
|
223
|
+
## Troubleshooting
|
|
224
|
+
|
|
225
|
+
### 404 Errors
|
|
226
|
+
If you're getting 404 errors, ensure your `CPLACE_URL` ends with a forward slash (`/`) when working with a tenant:
|
|
227
|
+
- ✅ Correct: `https://your-cplace-instance.com/your-tenant/`
|
|
228
|
+
- ❌ Incorrect: `https://your-cplace-instance.com/your-tenant`
|
package/dist/api.d.ts
CHANGED
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAe,MAAM,YAAY,CAAC;AAIvD,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,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,SAAS,MAAM,YAAY,EAC/C,QAAQ,EAAE,CAAC,EACX,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAC5C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAGrB,cAAc,CAAC,CAAC,GAAG,GAAG,EAC1B,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,EAC5C,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,IAAI,CAAC,EAAE,GAAG,GACT,OAAO,CAAC,CAAC,CAAC;CAuFd"}
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAsM9C,MAAM,OAAO,eAAe;IAClB,MAAM,CAAe;IAE7B,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAkBD,KAAK,CAAC,cAAc,CAClB,QAAgB,EAChB,SAA8C,KAAK,EACnD,MAA4B,EAC5B,IAAU;QAEV,eAAe,CAAC,YAAY,EAAE,UAAU,MAAM,yBAAyB,QAAQ,EAAE,CAAC,CAAC;QACnF,eAAe,CAAC,YAAY,EAAE,WAAW,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,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3
|
+
export declare function registerActiveTools(server: McpServer, client: CplaceApiClient, activeGroups: Set<string>): void;
|
|
4
|
+
//# sourceMappingURL=conditional-registration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-registration.d.ts","sourceRoot":"","sources":["../src/conditional-registration.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAmC3C,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,EACvB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,GACxB,IAAI,CAeN"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getRequiredModules } from './profiles.js';
|
|
2
|
+
import { debugLogWithTag } from './logger.js';
|
|
3
|
+
import { registerWorkspaceTools } from './tools/workspace.js';
|
|
4
|
+
import { registerPageTools } from './tools/pages.js';
|
|
5
|
+
import { registerSearchTools } from './tools/search.js';
|
|
6
|
+
import { registerUserTools } from './tools/users.js';
|
|
7
|
+
import { registerReferenceTools } from './tools/references.js';
|
|
8
|
+
import { registerWidgetTools } from './tools/widgets.js';
|
|
9
|
+
import { registerTypeLayoutTools } from './tools/type-layouts.js';
|
|
10
|
+
import { registerVersionHistoryTools } from './tools/version-history.js';
|
|
11
|
+
import { registerChangeListenerTools } from './tools/change-listeners.js';
|
|
12
|
+
import { registerValidatorTools } from './tools/validators.js';
|
|
13
|
+
import { registerPPTExportProfileTools } from './tools/ppt-export-profiles.js';
|
|
14
|
+
const MODULE_REGISTRY = {
|
|
15
|
+
'workspace': registerWorkspaceTools,
|
|
16
|
+
'pages': registerPageTools,
|
|
17
|
+
'search': registerSearchTools,
|
|
18
|
+
'users': registerUserTools,
|
|
19
|
+
'references': registerReferenceTools,
|
|
20
|
+
'widgets': registerWidgetTools,
|
|
21
|
+
'type-layouts': registerTypeLayoutTools,
|
|
22
|
+
'version-history': registerVersionHistoryTools,
|
|
23
|
+
'change-listeners': registerChangeListenerTools,
|
|
24
|
+
'validators': registerValidatorTools,
|
|
25
|
+
'ppt-export-profiles': registerPPTExportProfileTools
|
|
26
|
+
};
|
|
27
|
+
export function registerActiveTools(server, client, activeGroups) {
|
|
28
|
+
const requiredModules = getRequiredModules(activeGroups);
|
|
29
|
+
debugLogWithTag('MCP', `Loading modules: ${Array.from(requiredModules).join(', ')}`);
|
|
30
|
+
for (const moduleName of requiredModules) {
|
|
31
|
+
const registrationFunction = MODULE_REGISTRY[moduleName];
|
|
32
|
+
if (registrationFunction) {
|
|
33
|
+
registrationFunction(server, client);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
debugLogWithTag('MCP', `Warning: No registration function found for module '${moduleName}'`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=conditional-registration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conditional-registration.js","sourceRoot":"","sources":["../src/conditional-registration.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AAG/E,MAAM,eAAe,GAAyE;IAC5F,WAAW,EAAE,sBAAsB;IACnC,OAAO,EAAE,iBAAiB;IAC1B,QAAQ,EAAE,mBAAmB;IAC7B,OAAO,EAAE,iBAAiB;IAC1B,YAAY,EAAE,sBAAsB;IACpC,SAAS,EAAE,mBAAmB;IAC9B,cAAc,EAAE,uBAAuB;IACvC,iBAAiB,EAAE,2BAA2B;IAC9C,kBAAkB,EAAE,2BAA2B;IAC/C,YAAY,EAAE,sBAAsB;IACpC,qBAAqB,EAAE,6BAA6B;CACrD,CAAC;AAKF,MAAM,UAAU,mBAAmB,CACjC,MAAiB,EACjB,MAAuB,EACvB,YAAyB;IAGzB,MAAM,eAAe,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC;IAEzD,eAAe,CAAC,KAAK,EAAE,oBAAoB,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAGrF,KAAK,MAAM,UAAU,IAAI,eAAe,EAAE,CAAC;QACzC,MAAM,oBAAoB,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;QACzD,IAAI,oBAAoB,EAAE,CAAC;YACzB,oBAAoB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACvC,CAAC;aAAM,CAAC;YACN,eAAe,CAAC,KAAK,EAAE,uDAAuD,UAAU,GAAG,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
3
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
4
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5
|
+
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import express from "express";
|
|
7
|
+
import cors from "cors";
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
4
9
|
import * as dotenv from 'dotenv';
|
|
5
10
|
import { CplaceApiClient } from './api.js';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { registerSearchTools } from './tools/search.js';
|
|
9
|
-
import { registerUserTools } from './tools/users.js';
|
|
10
|
-
import { registerReferenceTools } from './tools/references.js';
|
|
11
|
-
import { registerWidgetTools } from './tools/widgets.js';
|
|
12
|
-
import { registerTypeLayoutTools } from './tools/type-layouts.js';
|
|
11
|
+
import { parseProfiles, getActiveTools, TOOL_GROUPS } from './profiles.js';
|
|
12
|
+
import { registerActiveTools } from './conditional-registration.js';
|
|
13
13
|
import { registerSystemTools } from './tools/system.js';
|
|
14
|
-
import {
|
|
14
|
+
import { debugLogWithTag } from './logger.js';
|
|
15
15
|
dotenv.config();
|
|
16
16
|
const config = {
|
|
17
17
|
url: process.env.CPLACE_URL || '',
|
|
@@ -19,26 +19,256 @@ const config = {
|
|
|
19
19
|
registerSystemInfoTool: process.env.REGISTER_SYSTEM_INFO_TOOL === 'true' || false,
|
|
20
20
|
};
|
|
21
21
|
const client = new CplaceApiClient(config);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
const activeGroups = parseProfiles(process.argv);
|
|
23
|
+
const activeTools = getActiveTools(activeGroups);
|
|
24
|
+
debugLogWithTag('MCP', '====================================');
|
|
25
|
+
debugLogWithTag('MCP', 'cplace MCP Server Profile Configuration');
|
|
26
|
+
debugLogWithTag('MCP', '====================================');
|
|
27
|
+
debugLogWithTag('MCP', `Active groups: ${Array.from(activeGroups).join(', ')}`);
|
|
28
|
+
debugLogWithTag('MCP', `Total tools to register: ${activeTools.size}`);
|
|
29
|
+
debugLogWithTag('MCP', '====================================');
|
|
30
|
+
function createStdioServer() {
|
|
31
|
+
const stdioServer = new McpServer({
|
|
32
|
+
name: `cplace-mcp-server`,
|
|
33
|
+
version: "1.0.0"
|
|
34
|
+
});
|
|
35
|
+
registerActiveTools(stdioServer, client, activeGroups);
|
|
36
|
+
registerSystemTools(stdioServer, config);
|
|
37
|
+
stdioServer.registerTool("cplace_profile_info", {
|
|
38
|
+
description: "Get information about active MCP profiles and available groups",
|
|
39
|
+
inputSchema: {},
|
|
40
|
+
annotations: { title: "Profile Information" }
|
|
41
|
+
}, async () => {
|
|
42
|
+
const groupDetails = Array.from(activeGroups).map(name => ({
|
|
43
|
+
name,
|
|
44
|
+
description: TOOL_GROUPS[name]?.description || 'Unknown group',
|
|
45
|
+
toolCount: TOOL_GROUPS[name]?.tools.length || 0,
|
|
46
|
+
tools: TOOL_GROUPS[name]?.tools || []
|
|
47
|
+
}));
|
|
48
|
+
const allGroups = Object.entries(TOOL_GROUPS).map(([name, group]) => ({
|
|
49
|
+
name,
|
|
50
|
+
description: group.description,
|
|
51
|
+
toolCount: group.tools.length,
|
|
52
|
+
active: activeGroups.has(name)
|
|
53
|
+
}));
|
|
54
|
+
return {
|
|
55
|
+
content: [{
|
|
56
|
+
type: "text",
|
|
57
|
+
text: JSON.stringify({
|
|
58
|
+
active_groups: Array.from(activeGroups),
|
|
59
|
+
total_active_tools: activeTools.size,
|
|
60
|
+
active_group_details: groupDetails,
|
|
61
|
+
all_available_groups: allGroups,
|
|
62
|
+
mode: "stdio",
|
|
63
|
+
credentials: {
|
|
64
|
+
cplace_url: config.url,
|
|
65
|
+
has_token: !!config.apiToken
|
|
66
|
+
},
|
|
67
|
+
usage_examples: {
|
|
68
|
+
minimal: "No --profiles argument (core only)",
|
|
69
|
+
page_editing: "--profiles=pages_write",
|
|
70
|
+
dashboard_dev: "--profiles=pages_write+layouts",
|
|
71
|
+
type_dev: "--profiles=types_write+low_code",
|
|
72
|
+
full_access: "--profiles=all"
|
|
73
|
+
}
|
|
74
|
+
}, null, 2)
|
|
75
|
+
}]
|
|
76
|
+
};
|
|
77
|
+
});
|
|
78
|
+
return stdioServer;
|
|
79
|
+
}
|
|
80
|
+
const isRemote = process.argv.includes('--remote') || process.env.MCP_TRANSPORT === 'http';
|
|
81
|
+
if (isRemote) {
|
|
82
|
+
startHttpServer();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
runServer();
|
|
86
|
+
}
|
|
35
87
|
async function runServer() {
|
|
88
|
+
const stdioServer = createStdioServer();
|
|
36
89
|
const transport = new StdioServerTransport();
|
|
37
|
-
await
|
|
38
|
-
|
|
90
|
+
await stdioServer.connect(transport);
|
|
91
|
+
debugLogWithTag('MCP', 'Server running on stdio');
|
|
92
|
+
}
|
|
93
|
+
function validateCredentials(cplaceUrl, apiToken) {
|
|
94
|
+
if (!cplaceUrl || !apiToken) {
|
|
95
|
+
return { valid: false, error: 'Missing cplace URL or API token' };
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
new URL(cplaceUrl);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
return { valid: false, error: 'Invalid cplace URL format' };
|
|
102
|
+
}
|
|
103
|
+
if (apiToken.length < 10) {
|
|
104
|
+
return { valid: false, error: 'API token appears to be too short' };
|
|
105
|
+
}
|
|
106
|
+
return { valid: true };
|
|
107
|
+
}
|
|
108
|
+
function createSessionServer(cplaceUrl, apiToken) {
|
|
109
|
+
const sessionClient = new CplaceApiClient({ url: cplaceUrl, apiToken });
|
|
110
|
+
const sessionServer = new McpServer({
|
|
111
|
+
name: `cplace-mcp-server`,
|
|
112
|
+
version: "1.0.0"
|
|
113
|
+
});
|
|
114
|
+
registerActiveTools(sessionServer, sessionClient, activeGroups);
|
|
115
|
+
registerSystemTools(sessionServer, { url: cplaceUrl, apiToken, registerSystemInfoTool: config.registerSystemInfoTool });
|
|
116
|
+
sessionServer.registerTool("cplace_profile_info", {
|
|
117
|
+
description: "Get information about active MCP profiles and available groups",
|
|
118
|
+
inputSchema: {},
|
|
119
|
+
annotations: { title: "Profile Information" }
|
|
120
|
+
}, async () => {
|
|
121
|
+
const groupDetails = Array.from(activeGroups).map(name => ({
|
|
122
|
+
name,
|
|
123
|
+
description: TOOL_GROUPS[name]?.description || 'Unknown group',
|
|
124
|
+
toolCount: TOOL_GROUPS[name]?.tools.length || 0,
|
|
125
|
+
tools: TOOL_GROUPS[name]?.tools || []
|
|
126
|
+
}));
|
|
127
|
+
const allGroups = Object.entries(TOOL_GROUPS).map(([name, group]) => ({
|
|
128
|
+
name,
|
|
129
|
+
description: group.description,
|
|
130
|
+
toolCount: group.tools.length,
|
|
131
|
+
active: activeGroups.has(name)
|
|
132
|
+
}));
|
|
133
|
+
return {
|
|
134
|
+
content: [{
|
|
135
|
+
type: "text",
|
|
136
|
+
text: JSON.stringify({
|
|
137
|
+
active_groups: Array.from(activeGroups),
|
|
138
|
+
total_active_tools: activeTools.size,
|
|
139
|
+
active_group_details: groupDetails,
|
|
140
|
+
all_available_groups: allGroups,
|
|
141
|
+
session_credentials: {
|
|
142
|
+
cplace_url: cplaceUrl,
|
|
143
|
+
has_token: !!apiToken
|
|
144
|
+
},
|
|
145
|
+
usage_examples: {
|
|
146
|
+
minimal: "No --profiles argument (core only)",
|
|
147
|
+
page_editing: "--profiles=pages_write",
|
|
148
|
+
dashboard_dev: "--profiles=pages_write+layouts",
|
|
149
|
+
type_dev: "--profiles=types_write+low_code",
|
|
150
|
+
full_access: "--profiles=all"
|
|
151
|
+
}
|
|
152
|
+
}, null, 2)
|
|
153
|
+
}]
|
|
154
|
+
};
|
|
155
|
+
});
|
|
156
|
+
return { server: sessionServer, client: sessionClient };
|
|
157
|
+
}
|
|
158
|
+
function startHttpServer() {
|
|
159
|
+
const app = express();
|
|
160
|
+
const port = process.env.PORT || 3000;
|
|
161
|
+
const sessions = {};
|
|
162
|
+
app.use(cors({
|
|
163
|
+
origin: '*',
|
|
164
|
+
credentials: true,
|
|
165
|
+
allowedHeaders: ['Content-Type', 'mcp-session-id', 'cplace-url', 'cplace-api-token'],
|
|
166
|
+
exposedHeaders: ['mcp-session-id']
|
|
167
|
+
}));
|
|
168
|
+
app.use(express.json());
|
|
169
|
+
app.get('/health', (req, res) => {
|
|
170
|
+
const sessionStats = Object.values(sessions).reduce((acc, session) => {
|
|
171
|
+
const host = new URL(session.credentials.cplaceUrl).hostname;
|
|
172
|
+
acc[host] = (acc[host] || 0) + 1;
|
|
173
|
+
return acc;
|
|
174
|
+
}, {});
|
|
175
|
+
res.json({
|
|
176
|
+
status: 'healthy',
|
|
177
|
+
timestamp: new Date().toISOString(),
|
|
178
|
+
activeSessions: Object.keys(sessions).length,
|
|
179
|
+
sessionsByHost: sessionStats
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
app.post('/mcp', async (req, res) => {
|
|
183
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
184
|
+
const cplaceUrl = req.headers['cplace-url'];
|
|
185
|
+
const apiToken = req.headers['cplace-api-token'];
|
|
186
|
+
let sessionInfo;
|
|
187
|
+
if (sessionId && sessions[sessionId]) {
|
|
188
|
+
debugLogWithTag('MCP', `📱 Reusing existing session: ${sessionId}`);
|
|
189
|
+
sessionInfo = sessions[sessionId];
|
|
190
|
+
}
|
|
191
|
+
else if (!sessionId && isInitializeRequest(req.body)) {
|
|
192
|
+
const validation = validateCredentials(cplaceUrl, apiToken);
|
|
193
|
+
if (!validation.valid) {
|
|
194
|
+
debugLogWithTag('MCP', `❌ Invalid credentials for new session: ${validation.error}`);
|
|
195
|
+
res.status(400).json({
|
|
196
|
+
jsonrpc: '2.0',
|
|
197
|
+
error: {
|
|
198
|
+
code: -32000,
|
|
199
|
+
message: `Bad Request: ${validation.error}`,
|
|
200
|
+
},
|
|
201
|
+
id: null,
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
debugLogWithTag('MCP', `🆕 Creating new MCP session for ${new URL(cplaceUrl).hostname}`);
|
|
206
|
+
const { server: sessionServer, client: sessionClient } = createSessionServer(cplaceUrl, apiToken);
|
|
207
|
+
const transport = new StreamableHTTPServerTransport({
|
|
208
|
+
sessionIdGenerator: () => randomUUID(),
|
|
209
|
+
onsessioninitialized: (newSessionId) => {
|
|
210
|
+
debugLogWithTag('MCP', `✅ Session initialized: ${newSessionId} for ${new URL(cplaceUrl).hostname}`);
|
|
211
|
+
sessions[newSessionId] = {
|
|
212
|
+
transport,
|
|
213
|
+
server: sessionServer,
|
|
214
|
+
client: sessionClient,
|
|
215
|
+
credentials: { cplaceUrl, apiToken }
|
|
216
|
+
};
|
|
217
|
+
},
|
|
218
|
+
enableDnsRebindingProtection: false,
|
|
219
|
+
allowedHosts: ['127.0.0.1', 'localhost'],
|
|
220
|
+
});
|
|
221
|
+
transport.onclose = () => {
|
|
222
|
+
if (transport.sessionId) {
|
|
223
|
+
debugLogWithTag('MCP', `🔚 Cleaning up session: ${transport.sessionId}`);
|
|
224
|
+
delete sessions[transport.sessionId];
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
await sessionServer.connect(transport);
|
|
228
|
+
sessionInfo = {
|
|
229
|
+
transport,
|
|
230
|
+
server: sessionServer,
|
|
231
|
+
client: sessionClient,
|
|
232
|
+
credentials: { cplaceUrl, apiToken }
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
debugLogWithTag('MCP', '❌ Invalid request: No valid session ID provided');
|
|
237
|
+
res.status(400).json({
|
|
238
|
+
jsonrpc: '2.0',
|
|
239
|
+
error: {
|
|
240
|
+
code: -32000,
|
|
241
|
+
message: 'Bad Request: No valid session ID provided',
|
|
242
|
+
},
|
|
243
|
+
id: null,
|
|
244
|
+
});
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
await sessionInfo.transport.handleRequest(req, res, req.body);
|
|
248
|
+
});
|
|
249
|
+
const handleSessionRequest = async (req, res) => {
|
|
250
|
+
const sessionId = req.headers['mcp-session-id'];
|
|
251
|
+
if (!sessionId || !sessions[sessionId]) {
|
|
252
|
+
debugLogWithTag('MCP', `❌ Invalid or missing session ID: ${sessionId}`);
|
|
253
|
+
res.status(400).send('Invalid or missing session ID');
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
const sessionInfo = sessions[sessionId];
|
|
257
|
+
debugLogWithTag('MCP', `🔄 Handling ${req.method} request for session: ${sessionId} (${new URL(sessionInfo.credentials.cplaceUrl).hostname})`);
|
|
258
|
+
await sessionInfo.transport.handleRequest(req, res);
|
|
259
|
+
};
|
|
260
|
+
app.get('/mcp', handleSessionRequest);
|
|
261
|
+
app.delete('/mcp', handleSessionRequest);
|
|
262
|
+
app.listen(port, () => {
|
|
263
|
+
debugLogWithTag('MCP', `🚀 Remote MCP server running on http://localhost:${port}`);
|
|
264
|
+
debugLogWithTag('MCP', `📡 MCP endpoint: http://localhost:${port}/mcp`);
|
|
265
|
+
debugLogWithTag('MCP', `🔧 Session management enabled with streamable-HTTP transport`);
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
if (!isRemote) {
|
|
269
|
+
runServer().catch((error) => {
|
|
270
|
+
debugLogWithTag('MCP', `Fatal error running server: ${error}`);
|
|
271
|
+
process.exit(1);
|
|
272
|
+
});
|
|
39
273
|
}
|
|
40
|
-
runServer().catch((error) => {
|
|
41
|
-
console.error("Fatal error running server:", error);
|
|
42
|
-
process.exit(1);
|
|
43
|
-
});
|
|
44
274
|
//# sourceMappingURL=index.js.map
|