@elastic.io/mcp 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 +191 -0
- package/README.md +171 -0
- package/dist/api/client.d.ts +12 -0
- package/dist/api/client.d.ts.map +1 -0
- package/dist/api/client.js +124 -0
- package/dist/api/client.js.map +1 -0
- package/dist/api/jsonapi.d.ts +28 -0
- package/dist/api/jsonapi.d.ts.map +1 -0
- package/dist/api/jsonapi.js +45 -0
- package/dist/api/jsonapi.js.map +1 -0
- package/dist/api/logger.d.ts +9 -0
- package/dist/api/logger.d.ts.map +1 -0
- package/dist/api/logger.js +46 -0
- package/dist/api/logger.js.map +1 -0
- package/dist/api/samples.d.ts +21 -0
- package/dist/api/samples.d.ts.map +1 -0
- package/dist/api/samples.js +465 -0
- package/dist/api/samples.js.map +1 -0
- package/dist/config.d.ts +16 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +49 -0
- package/dist/config.js.map +1 -0
- package/dist/embeddings/factory.d.ts +7 -0
- package/dist/embeddings/factory.d.ts.map +1 -0
- package/dist/embeddings/factory.js +25 -0
- package/dist/embeddings/factory.js.map +1 -0
- package/dist/embeddings/google.d.ts +19 -0
- package/dist/embeddings/google.d.ts.map +1 -0
- package/dist/embeddings/google.js +132 -0
- package/dist/embeddings/google.js.map +1 -0
- package/dist/embeddings/types.d.ts +27 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/embeddings/types.js +2 -0
- package/dist/embeddings/types.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +226 -0
- package/dist/index.js.map +1 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +10 -0
- package/dist/paths.js.map +1 -0
- package/dist/server.d.ts +29 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +361 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/confirmation.d.ts +41 -0
- package/dist/tools/confirmation.d.ts.map +1 -0
- package/dist/tools/confirmation.js +120 -0
- package/dist/tools/confirmation.js.map +1 -0
- package/dist/tools/constants.d.ts +31 -0
- package/dist/tools/constants.d.ts.map +1 -0
- package/dist/tools/constants.js +85 -0
- package/dist/tools/constants.js.map +1 -0
- package/dist/tools/definitions.d.ts +3 -0
- package/dist/tools/definitions.d.ts.map +1 -0
- package/dist/tools/definitions.js +883 -0
- package/dist/tools/definitions.js.map +1 -0
- package/dist/tools/handlers/auth.d.ts +3 -0
- package/dist/tools/handlers/auth.d.ts.map +1 -0
- package/dist/tools/handlers/auth.js +540 -0
- package/dist/tools/handlers/auth.js.map +1 -0
- package/dist/tools/handlers/component.d.ts +3 -0
- package/dist/tools/handlers/component.d.ts.map +1 -0
- package/dist/tools/handlers/component.js +145 -0
- package/dist/tools/handlers/component.js.map +1 -0
- package/dist/tools/handlers/data-sample.d.ts +3 -0
- package/dist/tools/handlers/data-sample.d.ts.map +1 -0
- package/dist/tools/handlers/data-sample.js +51 -0
- package/dist/tools/handlers/data-sample.js.map +1 -0
- package/dist/tools/handlers/dynamic.d.ts +3 -0
- package/dist/tools/handlers/dynamic.d.ts.map +1 -0
- package/dist/tools/handlers/dynamic.js +110 -0
- package/dist/tools/handlers/dynamic.js.map +1 -0
- package/dist/tools/handlers/flow.d.ts +9 -0
- package/dist/tools/handlers/flow.d.ts.map +1 -0
- package/dist/tools/handlers/flow.js +899 -0
- package/dist/tools/handlers/flow.js.map +1 -0
- package/dist/tools/handlers/log.d.ts +3 -0
- package/dist/tools/handlers/log.d.ts.map +1 -0
- package/dist/tools/handlers/log.js +61 -0
- package/dist/tools/handlers/log.js.map +1 -0
- package/dist/tools/handlers/organization.d.ts +3 -0
- package/dist/tools/handlers/organization.d.ts.map +1 -0
- package/dist/tools/handlers/organization.js +39 -0
- package/dist/tools/handlers/organization.js.map +1 -0
- package/dist/tools/handlers/raw.d.ts +3 -0
- package/dist/tools/handlers/raw.d.ts.map +1 -0
- package/dist/tools/handlers/raw.js +77 -0
- package/dist/tools/handlers/raw.js.map +1 -0
- package/dist/tools/handlers/search.d.ts +3 -0
- package/dist/tools/handlers/search.d.ts.map +1 -0
- package/dist/tools/handlers/search.js +82 -0
- package/dist/tools/handlers/search.js.map +1 -0
- package/dist/tools/handlers/session.d.ts +3 -0
- package/dist/tools/handlers/session.d.ts.map +1 -0
- package/dist/tools/handlers/session.js +15 -0
- package/dist/tools/handlers/session.js.map +1 -0
- package/dist/tools/handlers.d.ts +12 -0
- package/dist/tools/handlers.d.ts.map +1 -0
- package/dist/tools/handlers.js +197 -0
- package/dist/tools/handlers.js.map +1 -0
- package/dist/tools/helpers.d.ts +45 -0
- package/dist/tools/helpers.d.ts.map +1 -0
- package/dist/tools/helpers.js +195 -0
- package/dist/tools/helpers.js.map +1 -0
- package/dist/tools/types.d.ts +32 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +2 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/validation.d.ts +24 -0
- package/dist/tools/validation.d.ts.map +1 -0
- package/dist/tools/validation.js +748 -0
- package/dist/tools/validation.js.map +1 -0
- package/dist/types/index.d.ts +47 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/vectorstore/factory.d.ts +7 -0
- package/dist/vectorstore/factory.d.ts.map +1 -0
- package/dist/vectorstore/factory.js +25 -0
- package/dist/vectorstore/factory.js.map +1 -0
- package/dist/vectorstore/qdrant.d.ts +11 -0
- package/dist/vectorstore/qdrant.d.ts.map +1 -0
- package/dist/vectorstore/qdrant.js +107 -0
- package/dist/vectorstore/qdrant.js.map +1 -0
- package/dist/vectorstore/types.d.ts +28 -0
- package/dist/vectorstore/types.d.ts.map +1 -0
- package/dist/vectorstore/types.js +2 -0
- package/dist/vectorstore/types.js.map +1 -0
- package/package.json +51 -0
- package/resources/docs/component-test-scenarios.md +2468 -0
- package/resources/docs/credential-validation-gaps.md +35 -0
- package/resources/docs/debug-issues.md +71 -0
- package/resources/docs/deployment-and-scaling.md +136 -0
- package/resources/docs/flow-building-guide.md +565 -0
- package/resources/docs/packaging-plan.md +84 -0
- package/resources/docs/standardized-components-guide.md +66 -0
- package/resources/docs/system-instructions.md +177 -0
- package/resources/docs/unique-components.md +60 -0
- package/resources/docs/verified-creds-flow-ids.md +193 -0
- package/resources/flow-examples/batch-flow-1-collect.json +51 -0
- package/resources/flow-examples/batch-flow-2-process.json +70 -0
- package/resources/flow-examples/code-component-transform.json +65 -0
- package/resources/flow-examples/code-component-trigger.json +52 -0
- package/resources/flow-examples/code-component-with-credentials-trigger.json +53 -0
- package/resources/flow-examples/code-component-with-credentials.json +67 -0
- package/resources/flow-examples/filter-step.json +63 -0
- package/resources/flow-examples/polling-sync-trigger.json +50 -0
- package/resources/flow-examples/router-branching.json +94 -0
- package/resources/flow-examples/splitter-re-assemble.json +72 -0
- package/resources/flow-examples/splitter-split.json +68 -0
- package/resources/flow-examples/timer-query-action-sync.json +68 -0
- package/resources/flow-examples/webhook-async-sync.json +49 -0
- package/resources/flow-examples/webhook-request-reply.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 elastic.io GmbH
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# elastic.io Model Context Protocol (MCP) Server
|
|
2
|
+
|
|
3
|
+
A professional, production-ready TypeScript-based Model Context Protocol (MCP) server that connects Large Language Models (LLMs) to the **elastic.io** iPaaS platform REST API v2.
|
|
4
|
+
|
|
5
|
+
This server enables AI assistants (such as Antigravity, Claude Desktop, Cursor, or custom frontends) to discover, construct, modify, manage, and debug integration flows directly.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## What is the MCP Server?
|
|
10
|
+
|
|
11
|
+
This server implements the **Model Context Protocol (MCP)**, a standard protocol that lets LLMs securely query and mutate data in external systems.
|
|
12
|
+
|
|
13
|
+
Specifically, this server acts as an intelligent intermediary between an LLM agent and the elastic.io integration platform, exposing 32 distinct tools that translate high-level requests into raw API operations. It allows LLMs to list components, discover credentials, create and manage flows, build mappings with JSONata expressions, analyze run-time logs, and etc.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## How It Works
|
|
18
|
+
|
|
19
|
+
The server can run in two modes, depending on the transport protocol selected:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
[Stdio Mode (Local)]
|
|
23
|
+
LLM Client (Cursor) <--> [stdin / stdout] <--> MCP Server (uses static env keys)
|
|
24
|
+
|
|
25
|
+
[SSE Mode (Cloud)]
|
|
26
|
+
LLM Client (Browser/IDE) <--> [HTTP / SSE] <--> Express Server <--> Session Manager <--> Scoped MCP Server & Client (uses dynamic user keys)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### 1. Stdio Mode (Standard Input/Output)
|
|
30
|
+
* **Design:** Designed for a single developer working locally on an IDE (Cursor, Claude Desktop).
|
|
31
|
+
* **Process:** The LLM client starts the node server as a subprocess. Communication occurs over standard streams. The server loads static authentication credentials (`ELASTICIO_API_EMAIL` and `ELASTICIO_API_KEY`) from environment variables (or a local `.env` file).
|
|
32
|
+
|
|
33
|
+
### 2. SSE Mode (Server-Sent Events)
|
|
34
|
+
* **Design:** Designed to be hosted centrally in the cloud as a multi-tenant service.
|
|
35
|
+
* **Process:** The server runs an Express HTTP server.
|
|
36
|
+
* **Session Initialization:** The client connects to `GET /sse` passing an `Authorization` header containing their personal elastic.io email/API Key (Basic Auth).
|
|
37
|
+
* **Session Isolation:** The `SessionManager` captures this connection, generates a unique session ID, and spins up a dedicated `McpServer` and a request-scoped `Axios` instance. This guarantees that user credentials and API states are completely isolated.
|
|
38
|
+
* **Tool Calls:** The client POSTs JSON-RPC tool calls to `POST /messages` or `POST /sse`, supplying the `mcp-session-id` header to route the message to their isolated session.
|
|
39
|
+
|
|
40
|
+
### Core Safeguards & Optimizations
|
|
41
|
+
* **State-Machine Verification:** To prevent the LLM from configuring flows using cached or hallucinated IDs, the validation engine enforces that components and credentials must be fetched/discovered in the current session before they can be configured in a graph.
|
|
42
|
+
* **JSONata Safety Checks:** The server reviews generated mappings, warning the LLM if it wraps JSONata mappers in outer quotes (making them strings) or references variables directly instead of using `$getPassthrough().step_id.body.field`.
|
|
43
|
+
* **Token Optimization:** Component details are retrieved in two steps to prevent token bloat. Large metadata objects and enums are dynamically pruned when they exceed limits.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Execution Process & Requirements
|
|
48
|
+
|
|
49
|
+
### Requirements
|
|
50
|
+
* **Node.js** (version 18 or higher)
|
|
51
|
+
* **npm** or yarn
|
|
52
|
+
* **Embedding Provider API Key** (required for creating documentation and flow sample embeddings, e.g. Gemini).
|
|
53
|
+
* **Vector Store URL and API Key** (for semantic search capabilities, e.g. Qdrant).
|
|
54
|
+
|
|
55
|
+
### Local Setup
|
|
56
|
+
1. Clone this repository and install dependencies:
|
|
57
|
+
```bash
|
|
58
|
+
npm install
|
|
59
|
+
```
|
|
60
|
+
2. Copy `.env.example` to `.env` and fill out your variables:
|
|
61
|
+
```bash
|
|
62
|
+
cp .env.example .env
|
|
63
|
+
```
|
|
64
|
+
3. Build the project:
|
|
65
|
+
```bash
|
|
66
|
+
npm run build
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Running Locally (Stdio Mode)
|
|
70
|
+
To run the server locally inside your IDE (e.g. Cursor or Claude Desktop):
|
|
71
|
+
```bash
|
|
72
|
+
node dist/index.js
|
|
73
|
+
```
|
|
74
|
+
Configure your client configuration file (e.g., `mcp_config.json`) to invoke this command, providing the required environment variables:
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"mcpServers": {
|
|
78
|
+
"elasticio-mcp": {
|
|
79
|
+
"command": "node",
|
|
80
|
+
"args": ["/path/to/project/dist/index.js"],
|
|
81
|
+
"cwd": "/path/to/project",
|
|
82
|
+
"env": {
|
|
83
|
+
"ELASTICIO_API_EMAIL": "your_email@example.com",
|
|
84
|
+
"ELASTICIO_API_KEY": "your_api_key",
|
|
85
|
+
"EMBEDDING_PROVIDER_API_KEY": "your_embedding_provider_api_key",
|
|
86
|
+
"VECTOR_STORE_URL": "your_vector_store_url",
|
|
87
|
+
"VECTOR_STORE_API_KEY": "your_vector_store_api_key"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Running in Cloud Mode (SSE Mode)
|
|
95
|
+
To start the server in Server-Sent Events mode:
|
|
96
|
+
```bash
|
|
97
|
+
npm run start:sse
|
|
98
|
+
```
|
|
99
|
+
* The server will run on the port defined by the `PORT` environment variable (defaults to `3000`).
|
|
100
|
+
* Connect via the SSE endpoint `http://localhost:3000/sse` (or your cloud hosting URL) supplying your elastic.io credentials via basic auth.
|
|
101
|
+
|
|
102
|
+
#### Client Configuration (e.g., Cursor, Custom UI, or Antigravity)
|
|
103
|
+
To connect your local client to a hosted cloud instance, configure it to run over the HTTP/SSE transport instead of command lines:
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"mcpServers": {
|
|
107
|
+
"elasticio-mcp-cloud": {
|
|
108
|
+
"url": "https://your-mcp-server.yourdomain.com/sse",
|
|
109
|
+
"headers": {
|
|
110
|
+
"x-elasticio-email": "your_email@example.com",
|
|
111
|
+
"x-elasticio-api-key": "your_api_key"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
*Note: Alternatively, you can use the standard HTTP Basic Authentication header: `"Authorization": "Basic <base64_encoded_email_and_api_key>"`. Using `x-elasticio-email` and `x-elasticio-api-key` is recommended to avoid manually calculating base64 values.*
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Embedding & Ingestion Process
|
|
122
|
+
|
|
123
|
+
The server uses semantic search to locate documentation and similar flow configuration examples for the LLM. You must populate the vector database using one of two methods:
|
|
124
|
+
|
|
125
|
+
### 1. Ingesting Local Files
|
|
126
|
+
The project includes command-line scripts to parse, embed, and index local resources:
|
|
127
|
+
* **Ingest Documentation:** Parses the markdown files located in `resources/elasticio.github.io/content/` and uploads them to the Qdrant `documentation` collection:
|
|
128
|
+
```bash
|
|
129
|
+
node dist/scripts/ingest_docs.js
|
|
130
|
+
```
|
|
131
|
+
* **Ingest Flow Templates:** Parses the local JSON templates located in `resources/flow-examples/` and uploads them to the Qdrant `flow_samples` collection:
|
|
132
|
+
```bash
|
|
133
|
+
node dist/scripts/ingest_flow_examples.js
|
|
134
|
+
```
|
|
135
|
+
* **Verify Search:** Runs test search queries against Qdrant to confirm embeddings were correctly indexed:
|
|
136
|
+
```bash
|
|
137
|
+
node dist/scripts/test_search.js --query "your query string" --collection "flow_samples"
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### 2. Live Webhook Ingestion (SSE Mode)
|
|
141
|
+
When running in cloud/SSE mode, the server exposes an endpoint to ingest real-time flows directly from platform databases or sync scripts:
|
|
142
|
+
* **Endpoint:** `POST /api/samples` (accepts a JSON array of processed flows).
|
|
143
|
+
* **Execution Workflow:**
|
|
144
|
+
1. The server accepts the payload immediately with a `202 Accepted` response to prevent blocking network execution, then queues the tasks.
|
|
145
|
+
2. The background queue processing cleans and formats the flow structure, step settings, and JSONata mapper edges into a markdown document.
|
|
146
|
+
3. The structured text chunks are batched (up to 100 items per batch) and sent to the embedding API provider.
|
|
147
|
+
4. A 5-second delay is introduced between batches to respect API provider rate limits.
|
|
148
|
+
5. The resulting vectors are saved under the `flow_samples` collection in the vector database.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Limitations
|
|
153
|
+
|
|
154
|
+
If you deploy this MCP server to a cloud infrastructure, be aware of the following implementation limitations:
|
|
155
|
+
|
|
156
|
+
1. **In-Memory Rate Limiter:**
|
|
157
|
+
The connection rate limiter in `src/index.ts` records IP requests in an in-memory JavaScript `Map`. This has two drawbacks:
|
|
158
|
+
* **Stale IP Leak:** Connected IP keys are never removed from the map. In long-running public environments, this will cause a slow memory leak.
|
|
159
|
+
* **Clustering:** It cannot share rate limit state across multiple instances/containers running behind a load balancer. For production, replace it with `express-rate-limit` using a Redis store.
|
|
160
|
+
|
|
161
|
+
2. **Local Logging writes:**
|
|
162
|
+
The logger (`src/api/logger.ts`) is configured to append logs locally to a file named `mcp-server.log` on the filesystem, in addition to writing to `stderr`.
|
|
163
|
+
* **Ephemereal Storage:** Writing logs to local disk will eventually fill up ephemeral disk storage in container environments like AWS ECS or GCP Cloud Run.
|
|
164
|
+
* **Recommendation:** Disable local file writes in production, relying solely on standard output/error streaming.
|
|
165
|
+
|
|
166
|
+
3. **In-Memory Session Management (Boilerplate Code):**
|
|
167
|
+
The custom `SessionManager` manages stateful, multi-tenant mappings between SSE connection scopes and in-memory class instances. If the server process restarts, all active sessions are lost, causing `404` errors for connected clients until they re-establish connections.
|
|
168
|
+
* **Recommendation (Shifting to Mature Solutions):** For enterprise deployment, you should consider transitioning from in-memory session multiplexing to one of two mature architectural patterns:
|
|
169
|
+
* **3rd-Party Gateway/Proxy**: Run the MCP server in standard local `stdio` mode and wrap it using an off-the-shelf gateway (such as ContextForge Gateway, Apache APISIX with `mcp-bridge` plugin, or Supergateway). These gateways manage routing, SSL, authentication, and SSE session tracking out-of-the-box.
|
|
170
|
+
* **Infrastructure Isolation**: Deploy the server purely in `stdio` mode inside isolated, single-tenant container tasks (e.g. AWS ECS, GCP Cloud Run, or Fly.io micro-VMs) scheduled on-demand by a cloud orchestrator. This provides strict process-level security isolation and delegates lifecycles to your cloud provider, eliminating the need to write custom reapers or session hydration logic.
|
|
171
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
export declare class ElasticioApiError extends Error {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
statusText: string;
|
|
5
|
+
errors: any[];
|
|
6
|
+
constructor(statusCode: number, statusText: string, errors: any[], message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class ElasticioNetworkError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
export declare function createElasticioClient(authHeader: string, apiBaseUrl?: string): AxiosInstance;
|
|
12
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA+B7C,qBAAa,iBAAkB,SAAQ,KAAK;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,GAAG,EAAE,CAAC;gBAET,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,MAAM;CAQnF;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,OAAO,EAAE,MAAM;CAK5B;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,aAAa,CAuF5F"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
import { logger } from './logger.js';
|
|
3
|
+
import { maskSensitiveData } from '../tools/helpers.js';
|
|
4
|
+
const DEFAULT_BASE_URL = 'https://api.elastic.io/v2';
|
|
5
|
+
function formatPayloadForLog(data) {
|
|
6
|
+
if (!data)
|
|
7
|
+
return '';
|
|
8
|
+
try {
|
|
9
|
+
let parsedData = data;
|
|
10
|
+
let wasString = false;
|
|
11
|
+
if (typeof data === 'string') {
|
|
12
|
+
try {
|
|
13
|
+
parsedData = JSON.parse(data);
|
|
14
|
+
wasString = true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
// Raw string
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const masked = maskSensitiveData(parsedData);
|
|
21
|
+
const str = wasString && typeof masked !== 'string' ? JSON.stringify(masked) : (typeof masked === 'object' ? JSON.stringify(masked) : String(masked));
|
|
22
|
+
if (str.length > 2000) {
|
|
23
|
+
return ` - Payload (truncated): ${str.substring(0, 2000)}... [truncated ${str.length - 2000} chars]`;
|
|
24
|
+
}
|
|
25
|
+
return ` - Payload: ${str}`;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return ' - Payload: [Error formatting payload]';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export class ElasticioApiError extends Error {
|
|
32
|
+
statusCode;
|
|
33
|
+
statusText;
|
|
34
|
+
errors;
|
|
35
|
+
constructor(statusCode, statusText, errors, message) {
|
|
36
|
+
super(message);
|
|
37
|
+
this.name = 'ElasticioApiError';
|
|
38
|
+
this.statusCode = statusCode;
|
|
39
|
+
this.statusText = statusText;
|
|
40
|
+
this.errors = errors;
|
|
41
|
+
Object.setPrototypeOf(this, ElasticioApiError.prototype);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class ElasticioNetworkError extends Error {
|
|
45
|
+
constructor(message) {
|
|
46
|
+
super(message);
|
|
47
|
+
this.name = 'ElasticioNetworkError';
|
|
48
|
+
Object.setPrototypeOf(this, ElasticioNetworkError.prototype);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export function createElasticioClient(authHeader, apiBaseUrl) {
|
|
52
|
+
const baseURL = apiBaseUrl || process.env.ELASTICIO_API_BASE_URL || DEFAULT_BASE_URL;
|
|
53
|
+
const client = axios.create({
|
|
54
|
+
baseURL,
|
|
55
|
+
timeout: 30000,
|
|
56
|
+
maxRedirects: 0,
|
|
57
|
+
headers: {
|
|
58
|
+
'Authorization': authHeader,
|
|
59
|
+
'Content-Type': 'application/json',
|
|
60
|
+
'Accept': 'application/json'
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
client.interceptors.request.use((config) => {
|
|
64
|
+
const dataStr = formatPayloadForLog(config.data);
|
|
65
|
+
logger.info(`[HTTP Request] ${config.method?.toUpperCase()} ${baseURL}${config.url || ''}${dataStr}`);
|
|
66
|
+
return config;
|
|
67
|
+
});
|
|
68
|
+
client.interceptors.response.use((response) => {
|
|
69
|
+
const dataStr = formatPayloadForLog(response.data);
|
|
70
|
+
logger.info(`[HTTP Response] ${response.status} ${response.statusText}${dataStr}`);
|
|
71
|
+
return response;
|
|
72
|
+
}, async (error) => {
|
|
73
|
+
const config = error.config;
|
|
74
|
+
if (config) {
|
|
75
|
+
const status = error.response ? error.response.status : null;
|
|
76
|
+
const isRateLimit = status === 429;
|
|
77
|
+
const isTransientError = status && status >= 500 && status <= 599;
|
|
78
|
+
const isNetworkOrTimeout = !error.response || error.code === 'ECONNABORTED' || error.code === 'ETIMEDOUT' || error.message?.includes('timeout') || error.message?.includes('Network Error');
|
|
79
|
+
const configWithRetry = config;
|
|
80
|
+
configWithRetry.__retryCount = configWithRetry.__retryCount || 0;
|
|
81
|
+
const maxRetries = 3;
|
|
82
|
+
if ((isRateLimit || isTransientError || isNetworkOrTimeout) && configWithRetry.__retryCount < maxRetries) {
|
|
83
|
+
configWithRetry.__retryCount += 1;
|
|
84
|
+
const delay = Math.pow(2, configWithRetry.__retryCount) * 1000;
|
|
85
|
+
logger.warn(`[HTTP Retry] ${isNetworkOrTimeout ? 'Network/Timeout Error' : `Status ${status}`} on ${config.method?.toUpperCase()} ${config.url}. Retrying in ${delay / 1000}s (Attempt ${configWithRetry.__retryCount}/${maxRetries})...`);
|
|
86
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
87
|
+
return client(config);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (error.config && error.config.headers) {
|
|
91
|
+
for (const key of Object.keys(error.config.headers)) {
|
|
92
|
+
if (key.toLowerCase() === 'authorization') {
|
|
93
|
+
error.config.headers[key] = '*** REDACTED ***';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const status = error.response ? `${error.response.status} ${error.response.statusText}` : 'NETWORK_ERROR';
|
|
98
|
+
const errorDataStr = error.response?.data ? ` - Response: ${JSON.stringify(error.response.data)}` : '';
|
|
99
|
+
logger.error(`[HTTP Failure] Status: ${status} - URL: ${error.config?.url}${errorDataStr}`);
|
|
100
|
+
if (error.response && error.response.data && Array.isArray(error.response.data.errors)) {
|
|
101
|
+
const errors = error.response.data.errors;
|
|
102
|
+
const errorDetails = errors
|
|
103
|
+
.map((err) => {
|
|
104
|
+
const title = err.title ? `[${err.title}]` : '';
|
|
105
|
+
const detail = err.detail || '';
|
|
106
|
+
const pointer = err.source && err.source.pointer ? ` at ${err.source.pointer}` : '';
|
|
107
|
+
return `${title} ${detail}${pointer}`.trim();
|
|
108
|
+
})
|
|
109
|
+
.join('; ');
|
|
110
|
+
const msg = `elastic.io API Error (${error.response.status} ${error.response.statusText}): ${errorDetails}`;
|
|
111
|
+
logger.error(`[Unpacked API Error] ${msg}`);
|
|
112
|
+
throw new ElasticioApiError(error.response.status, error.response.statusText, errors, msg);
|
|
113
|
+
}
|
|
114
|
+
if (error.response) {
|
|
115
|
+
const fallbackMsg = `elastic.io API Request failed (${error.response.status} ${error.response.statusText})`;
|
|
116
|
+
logger.error(`[Unpacked HTTP Error] ${fallbackMsg}`);
|
|
117
|
+
throw new ElasticioApiError(error.response.status, error.response.statusText, [], fallbackMsg);
|
|
118
|
+
}
|
|
119
|
+
logger.error(`[Network Error] ${error.message}`);
|
|
120
|
+
throw new ElasticioNetworkError(error.message);
|
|
121
|
+
});
|
|
122
|
+
return client;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC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AC7F,CAAC;QAED,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,WAAW,GAAG,kCAAkC,KAAK,CAAC,QAAQ,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,GAAG,CAAC;YAC5G,MAAM,CAAC,KAAK,CAAC,yBAAyB,WAAW,EAAE,CAAC,CAAC;YACrD,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,EAAE,EAAE,EAAE,WAAW,CAAC,CAAC;QACjG,CAAC;QAED,MAAM,CAAC,KAAK,CAAC,mBAAmB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QACjD,MAAM,IAAI,qBAAqB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface PaginationMeta {
|
|
2
|
+
page: number;
|
|
3
|
+
perPage: number;
|
|
4
|
+
totalPages: number;
|
|
5
|
+
total: number;
|
|
6
|
+
}
|
|
7
|
+
export interface DeserializedResult<T = any> {
|
|
8
|
+
data: T;
|
|
9
|
+
meta?: PaginationMeta;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Deserializes a JSON API response payload (with data, attributes, relationships, etc.)
|
|
13
|
+
* into a clean JavaScript object or array of objects.
|
|
14
|
+
*/
|
|
15
|
+
export declare function deserializeJsonApi<T = any>(payload: any): T;
|
|
16
|
+
/**
|
|
17
|
+
* Deserializes a JSON API response and preserves pagination metadata.
|
|
18
|
+
*/
|
|
19
|
+
export declare function deserializeWithMeta<T = any>(payload: any): DeserializedResult<T>;
|
|
20
|
+
/**
|
|
21
|
+
* Serializes a clean JavaScript object into a JSON API compliant request payload.
|
|
22
|
+
*
|
|
23
|
+
* @param model The resource type (e.g., 'flows', 'workspaces')
|
|
24
|
+
* @param data The payload data to serialize
|
|
25
|
+
* @param method The HTTP method of the request ('POST', 'PATCH', etc.)
|
|
26
|
+
*/
|
|
27
|
+
export declare function serializeJsonApi(model: string, data: any, method?: 'POST' | 'PATCH' | 'PUT' | 'GET'): any;
|
|
28
|
+
//# sourceMappingURL=jsonapi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonapi.d.ts","sourceRoot":"","sources":["../../src/api/jsonapi.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,GAAG;IACzC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,cAAc,CAAC;CACvB;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,CAM3D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EAAE,OAAO,EAAE,GAAG,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAehF;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,KAAc,GAAG,GAAG,CAKjH"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { deserialise, serialise } from 'kitsu-core';
|
|
2
|
+
/**
|
|
3
|
+
* Deserializes a JSON API response payload (with data, attributes, relationships, etc.)
|
|
4
|
+
* into a clean JavaScript object or array of objects.
|
|
5
|
+
*/
|
|
6
|
+
export function deserializeJsonApi(payload) {
|
|
7
|
+
if (!payload || (typeof payload !== 'object')) {
|
|
8
|
+
return payload;
|
|
9
|
+
}
|
|
10
|
+
const result = deserialise(payload);
|
|
11
|
+
return result.data;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Deserializes a JSON API response and preserves pagination metadata.
|
|
15
|
+
*/
|
|
16
|
+
export function deserializeWithMeta(payload) {
|
|
17
|
+
if (!payload || (typeof payload !== 'object')) {
|
|
18
|
+
return { data: payload };
|
|
19
|
+
}
|
|
20
|
+
const result = deserialise(payload);
|
|
21
|
+
const pageMeta = payload.meta?.page;
|
|
22
|
+
return {
|
|
23
|
+
data: result.data,
|
|
24
|
+
meta: pageMeta ? {
|
|
25
|
+
page: pageMeta.number || 1,
|
|
26
|
+
perPage: pageMeta.size || pageMeta.count || 0,
|
|
27
|
+
totalPages: Math.ceil((pageMeta.total_count || 0) / (pageMeta.size || 1)),
|
|
28
|
+
total: pageMeta.total_count || 0
|
|
29
|
+
} : undefined
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Serializes a clean JavaScript object into a JSON API compliant request payload.
|
|
34
|
+
*
|
|
35
|
+
* @param model The resource type (e.g., 'flows', 'workspaces')
|
|
36
|
+
* @param data The payload data to serialize
|
|
37
|
+
* @param method The HTTP method of the request ('POST', 'PATCH', etc.)
|
|
38
|
+
*/
|
|
39
|
+
export function serializeJsonApi(model, data, method = 'POST') {
|
|
40
|
+
return serialise(model, data, method, {
|
|
41
|
+
camelCaseTypes: (s) => s,
|
|
42
|
+
pluralTypes: (s) => s
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=jsonapi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonapi.js","sourceRoot":"","sources":["../../src/api/jsonapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAcpD;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAU,OAAY;IACtD,IAAI,CAAC,OAAO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C;AACL,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
|
|
2
|
+
export declare const logger: {
|
|
3
|
+
debug: (message: string, ...args: any[]) => void;
|
|
4
|
+
info: (message: string, ...args: any[]) => void;
|
|
5
|
+
warn: (message: string, ...args: any[]) => void;
|
|
6
|
+
error: (message: string, ...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare function logMcp(message: string): void;
|
|
9
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/api/logger.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AA2C3D,eAAO,MAAM,MAAM;qBACA,MAAM,WAAW,GAAG,EAAE;oBACvB,MAAM,WAAW,GAAG,EAAE;oBACtB,MAAM,WAAW,GAAG,EAAE;qBACrB,MAAM,WAAW,GAAG,EAAE;CACxC,CAAC;AAGF,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,QAErC"}
|