@rawdash/mcp 0.1.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 +202 -0
- package/README.md +82 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +534 -0
- package/dist/index.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
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 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 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 those 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
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @rawdash/mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/@rawdash/mcp)
|
|
4
|
+
[](https://github.com/rawdash/rawdash/blob/main/LICENSE)
|
|
5
|
+
|
|
6
|
+
MCP server exposing rawdash dashboards to LLMs and AI agents.
|
|
7
|
+
|
|
8
|
+
## What it is
|
|
9
|
+
|
|
10
|
+
`@rawdash/mcp` implements the [Model Context Protocol](https://modelcontextprotocol.io/) on top of a rawdash config. It gives any MCP-compatible AI assistant (Claude, Cursor, etc.) direct tool access to your dashboards: listing dashboards and widgets, reading widget data, managing connectors, handling secrets, and triggering syncs — all as structured tool calls.
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @rawdash/mcp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick example
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio';
|
|
22
|
+
import { createMcpServer } from '@rawdash/mcp';
|
|
23
|
+
|
|
24
|
+
import config from './rawdash.config';
|
|
25
|
+
import { storage } from './storage';
|
|
26
|
+
|
|
27
|
+
const server = createMcpServer({ config, storage });
|
|
28
|
+
await server.connect(new StdioServerTransport());
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Claude Desktop config
|
|
32
|
+
|
|
33
|
+
Add this to your `claude_desktop_config.json`:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"mcpServers": {
|
|
38
|
+
"rawdash": {
|
|
39
|
+
"command": "node",
|
|
40
|
+
"args": ["/path/to/your/mcp-server.js"]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Available tools
|
|
47
|
+
|
|
48
|
+
| Tool | Description |
|
|
49
|
+
| ------------------ | ----------------------------------------------- |
|
|
50
|
+
| `list_dashboards` | List all configured dashboards |
|
|
51
|
+
| `list_widgets` | List widgets in a dashboard |
|
|
52
|
+
| `read_widget` | Read cached data for a widget |
|
|
53
|
+
| `render_widget` | Render a widget as formatted text |
|
|
54
|
+
| `list_connectors` | List configured connectors and their sync state |
|
|
55
|
+
| `add_connector` | Add a new connector at runtime |
|
|
56
|
+
| `remove_connector` | Remove a connector |
|
|
57
|
+
| `trigger_sync` | Trigger an immediate data sync |
|
|
58
|
+
| `set_secret` | Set a secret value |
|
|
59
|
+
| `list_secrets` | List tracked secret names |
|
|
60
|
+
|
|
61
|
+
## API
|
|
62
|
+
|
|
63
|
+
### `createMcpServer(options): McpServer`
|
|
64
|
+
|
|
65
|
+
Creates and returns an `McpServer` instance with all tools registered. Options:
|
|
66
|
+
|
|
67
|
+
| Option | Type | Description |
|
|
68
|
+
| --------- | ----------------- | ----------------------------------------- |
|
|
69
|
+
| `config` | `DashboardConfig` | Your rawdash config (from `defineConfig`) |
|
|
70
|
+
| `storage` | `ServerStorage` | Storage backend (e.g. `TursoStorage`) |
|
|
71
|
+
| `name` | `string` | MCP server name (default: `'rawdash'`) |
|
|
72
|
+
| `version` | `string` | MCP server version (default: `'1.0.0'`) |
|
|
73
|
+
|
|
74
|
+
## Links
|
|
75
|
+
|
|
76
|
+
- [rawdash docs](https://rawdash.dev)
|
|
77
|
+
- [GitHub](https://github.com/rawdash/rawdash)
|
|
78
|
+
- [Issues](https://github.com/rawdash/rawdash/issues)
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';
|
|
2
|
+
import { ConnectorEntry, DashboardConfig } from '@rawdash/core';
|
|
3
|
+
import { ServerStorage } from '@rawdash/server';
|
|
4
|
+
import { ZodObject, ZodRawShape } from 'zod';
|
|
5
|
+
|
|
6
|
+
interface McpError {
|
|
7
|
+
error: {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
interface ConnectorFactory {
|
|
13
|
+
id: string;
|
|
14
|
+
configFields: ZodObject<ZodRawShape>;
|
|
15
|
+
create(settings: unknown): ConnectorEntry;
|
|
16
|
+
}
|
|
17
|
+
interface McpServerOptions {
|
|
18
|
+
name?: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
config: DashboardConfig;
|
|
21
|
+
storage: ServerStorage;
|
|
22
|
+
connectorFactories?: ConnectorFactory[];
|
|
23
|
+
onAddConnector?: (entry: ConnectorEntry) => void | Promise<void>;
|
|
24
|
+
onRemoveConnector?: (connectorId: string) => void | Promise<void>;
|
|
25
|
+
onSetSecret?: (name: string, value: string) => void | Promise<void>;
|
|
26
|
+
listSecrets?: () => string[] | Promise<string[]>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
declare function createMcpServer(options: McpServerOptions): McpServer;
|
|
30
|
+
|
|
31
|
+
export { type ConnectorFactory, type McpError, type McpServerOptions, createMcpServer };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,534 @@
|
|
|
1
|
+
// src/server.ts
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp";
|
|
3
|
+
|
|
4
|
+
// src/runtime-config.ts
|
|
5
|
+
var RuntimeConfig = class {
|
|
6
|
+
connectors;
|
|
7
|
+
dashboards;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.connectors = [...config.connectors];
|
|
10
|
+
this.dashboards = config.dashboards;
|
|
11
|
+
}
|
|
12
|
+
getConnectors() {
|
|
13
|
+
return [...this.connectors];
|
|
14
|
+
}
|
|
15
|
+
getDashboards() {
|
|
16
|
+
return this.dashboards;
|
|
17
|
+
}
|
|
18
|
+
addConnector(entry) {
|
|
19
|
+
if (this.connectors.some((e) => e.connector.id === entry.connector.id)) {
|
|
20
|
+
throw new Error(`Connector "${entry.connector.id}" already exists`);
|
|
21
|
+
}
|
|
22
|
+
this.connectors = [...this.connectors, entry];
|
|
23
|
+
}
|
|
24
|
+
removeConnector(connectorId) {
|
|
25
|
+
const before = this.connectors.length;
|
|
26
|
+
this.connectors = this.connectors.filter(
|
|
27
|
+
(e) => e.connector.id !== connectorId
|
|
28
|
+
);
|
|
29
|
+
return this.connectors.length < before;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/tools/add-connector.ts
|
|
34
|
+
import { z } from "zod";
|
|
35
|
+
|
|
36
|
+
// src/tools/shared.ts
|
|
37
|
+
function safeStringify(data) {
|
|
38
|
+
try {
|
|
39
|
+
return JSON.stringify(
|
|
40
|
+
data,
|
|
41
|
+
(_key, value) => typeof value === "bigint" ? value.toString() : value,
|
|
42
|
+
2
|
|
43
|
+
);
|
|
44
|
+
} catch {
|
|
45
|
+
return JSON.stringify(
|
|
46
|
+
{
|
|
47
|
+
error: {
|
|
48
|
+
code: "SERIALIZATION_ERROR",
|
|
49
|
+
message: "Failed to serialize tool response"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
null,
|
|
53
|
+
2
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function text(data) {
|
|
58
|
+
return {
|
|
59
|
+
content: [{ type: "text", text: safeStringify(data) }]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function err(code, message) {
|
|
63
|
+
return text({ error: { code, message } });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/tools/add-connector.ts
|
|
67
|
+
function registerAddConnector(server, runtime, options) {
|
|
68
|
+
server.tool(
|
|
69
|
+
"add_connector",
|
|
70
|
+
"Add a connector instance to this Rawdash instance. Settings are validated against the connector's configFields schema. For OSS, this is a runtime-only change (not persisted to disk).",
|
|
71
|
+
{
|
|
72
|
+
connector_type: z.string().describe(
|
|
73
|
+
'The connector type ID (e.g. "github-actions"). Use list_connectors to see available types.'
|
|
74
|
+
),
|
|
75
|
+
settings: z.record(z.string(), z.unknown()).describe(
|
|
76
|
+
"Connector settings as a JSON object. Schema depends on the connector type."
|
|
77
|
+
)
|
|
78
|
+
},
|
|
79
|
+
async ({ connector_type, settings }) => {
|
|
80
|
+
const factories = options.connectorFactories ?? [];
|
|
81
|
+
const factory = factories.find((f) => f.id === connector_type);
|
|
82
|
+
if (!factory) {
|
|
83
|
+
const available = factories.map((f) => f.id);
|
|
84
|
+
return err(
|
|
85
|
+
"UNKNOWN_CONNECTOR_TYPE",
|
|
86
|
+
available.length > 0 ? `Unknown connector type "${connector_type}". Available: ${available.join(", ")}` : `Unknown connector type "${connector_type}". No connector factories are registered.`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const parsed = factory.configFields.safeParse(settings);
|
|
90
|
+
if (!parsed.success) {
|
|
91
|
+
const issues = parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
92
|
+
return err("INVALID_SETTINGS", `Invalid settings: ${issues}`);
|
|
93
|
+
}
|
|
94
|
+
let entry;
|
|
95
|
+
try {
|
|
96
|
+
entry = factory.create(parsed.data);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
return err(
|
|
99
|
+
"CREATE_FAILED",
|
|
100
|
+
`Failed to create connector: ${e instanceof Error ? e.message : String(e)}`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
try {
|
|
104
|
+
runtime.addConnector(entry);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
return err(
|
|
107
|
+
"ALREADY_EXISTS",
|
|
108
|
+
e instanceof Error ? e.message : String(e)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
await options.onAddConnector?.(entry);
|
|
113
|
+
} catch (e) {
|
|
114
|
+
return err(
|
|
115
|
+
"ON_ADD_CONNECTOR_FAILED",
|
|
116
|
+
`Connector added in-memory but post-add callback failed: ${e instanceof Error ? e.message : String(e)}`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
return text({ added: entry.connector.id, idempotent: false });
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/tools/list-connectors.ts
|
|
125
|
+
function registerListConnectors(server, runtime, storage) {
|
|
126
|
+
server.tool(
|
|
127
|
+
"list_connectors",
|
|
128
|
+
"List all configured connectors and their sync status.",
|
|
129
|
+
{},
|
|
130
|
+
async () => {
|
|
131
|
+
try {
|
|
132
|
+
const syncState = await storage.getSyncState();
|
|
133
|
+
const connectors = runtime.getConnectors().map((entry) => ({
|
|
134
|
+
id: entry.connector.id,
|
|
135
|
+
syncStatus: syncState.status,
|
|
136
|
+
lastSyncAt: syncState.lastSyncAt,
|
|
137
|
+
lastError: syncState.lastError,
|
|
138
|
+
hasCredentials: Object.keys(entry.connector.credentials ?? {}).length > 0,
|
|
139
|
+
credentialKeys: Object.keys(entry.connector.credentials ?? {})
|
|
140
|
+
}));
|
|
141
|
+
return text({ connectors, overallSyncStatus: syncState.status });
|
|
142
|
+
} catch (e) {
|
|
143
|
+
return err(
|
|
144
|
+
"LIST_CONNECTORS_FAILED",
|
|
145
|
+
e instanceof Error ? e.message : String(e)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// src/tools/list-dashboards.ts
|
|
153
|
+
function registerListDashboards(server, runtime) {
|
|
154
|
+
server.tool(
|
|
155
|
+
"list_dashboards",
|
|
156
|
+
"List all dashboards available on this Rawdash instance.",
|
|
157
|
+
{},
|
|
158
|
+
() => {
|
|
159
|
+
const dashboards = Object.entries(runtime.getDashboards()).map(
|
|
160
|
+
([id, dashboard]) => ({
|
|
161
|
+
id,
|
|
162
|
+
widgetCount: Object.keys(dashboard.widgets).length,
|
|
163
|
+
widgetIds: Object.keys(dashboard.widgets)
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
return Promise.resolve(text({ dashboards }));
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/tools/list-secrets.ts
|
|
172
|
+
function registerListSecrets(server, trackedSecrets, options) {
|
|
173
|
+
server.tool(
|
|
174
|
+
"list_secrets",
|
|
175
|
+
"List secret names known to this Rawdash instance. Values are never returned.",
|
|
176
|
+
{},
|
|
177
|
+
async () => {
|
|
178
|
+
try {
|
|
179
|
+
const names = options.listSecrets ? await options.listSecrets() : [...trackedSecrets];
|
|
180
|
+
return text({ secrets: [...names].sort() });
|
|
181
|
+
} catch (e) {
|
|
182
|
+
return err(
|
|
183
|
+
"LIST_SECRETS_FAILED",
|
|
184
|
+
e instanceof Error ? e.message : "Failed to list secrets."
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// src/tools/list-widgets.ts
|
|
192
|
+
import { z as z2 } from "zod";
|
|
193
|
+
function registerListWidgets(server, runtime) {
|
|
194
|
+
server.tool(
|
|
195
|
+
"list_widgets",
|
|
196
|
+
"List all widgets on a dashboard.",
|
|
197
|
+
{
|
|
198
|
+
dashboard_id: z2.string().describe("The dashboard ID to list widgets for.")
|
|
199
|
+
},
|
|
200
|
+
({ dashboard_id }) => {
|
|
201
|
+
const dashboard = runtime.getDashboards()[dashboard_id];
|
|
202
|
+
if (!dashboard) {
|
|
203
|
+
return Promise.resolve(
|
|
204
|
+
err("NOT_FOUND", `Dashboard "${dashboard_id}" not found`)
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
const widgets = Object.entries(dashboard.widgets).map(([id, widget]) => ({
|
|
208
|
+
id,
|
|
209
|
+
kind: widget.kind,
|
|
210
|
+
title: widget.title,
|
|
211
|
+
...widget.kind !== "status" ? { connectorId: widget.metric.connectorId } : { source: widget.source }
|
|
212
|
+
}));
|
|
213
|
+
return Promise.resolve(text({ dashboard_id, widgets }));
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// src/tools/read-widget.ts
|
|
219
|
+
import { computeMetric } from "@rawdash/server";
|
|
220
|
+
import { z as z3 } from "zod";
|
|
221
|
+
function registerReadWidget(server, runtime, storage) {
|
|
222
|
+
server.tool(
|
|
223
|
+
"read_widget",
|
|
224
|
+
"Fetch resolved widget data. Returns the same shape as the HTTP read API.",
|
|
225
|
+
{
|
|
226
|
+
dashboard_id: z3.string().describe("The dashboard ID."),
|
|
227
|
+
widget_id: z3.string().describe("The widget ID.")
|
|
228
|
+
},
|
|
229
|
+
async ({ dashboard_id, widget_id }) => {
|
|
230
|
+
try {
|
|
231
|
+
const dashboard = runtime.getDashboards()[dashboard_id];
|
|
232
|
+
if (!dashboard) {
|
|
233
|
+
return err("NOT_FOUND", `Dashboard "${dashboard_id}" not found`);
|
|
234
|
+
}
|
|
235
|
+
const widget = dashboard.widgets[widget_id];
|
|
236
|
+
if (!widget) {
|
|
237
|
+
return err("NOT_FOUND", `Widget "${widget_id}" not found`);
|
|
238
|
+
}
|
|
239
|
+
if (widget.kind === "status") {
|
|
240
|
+
const syncState2 = await storage.getSyncState();
|
|
241
|
+
return text({
|
|
242
|
+
id: widget_id,
|
|
243
|
+
widgetId: widget_id,
|
|
244
|
+
connectorId: widget.source,
|
|
245
|
+
data: null,
|
|
246
|
+
cachedAt: syncState2.lastSyncAt
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
const { connectorId } = widget.metric;
|
|
250
|
+
const connectorEntry = runtime.getConnectors().find((e) => e.connector.id === connectorId);
|
|
251
|
+
if (!connectorEntry) {
|
|
252
|
+
return err(
|
|
253
|
+
"CONNECTOR_NOT_FOUND",
|
|
254
|
+
`Connector "${connectorId}" not found`
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
const handle = storage.getStorageHandle(connectorId);
|
|
258
|
+
const data = await computeMetric(handle, widget.metric);
|
|
259
|
+
const syncState = await storage.getSyncState();
|
|
260
|
+
return text({
|
|
261
|
+
id: widget_id,
|
|
262
|
+
widgetId: widget_id,
|
|
263
|
+
connectorId,
|
|
264
|
+
data,
|
|
265
|
+
cachedAt: syncState.lastSyncAt
|
|
266
|
+
});
|
|
267
|
+
} catch (e) {
|
|
268
|
+
return err("READ_FAILED", e instanceof Error ? e.message : String(e));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/tools/remove-connector.ts
|
|
275
|
+
import { z as z4 } from "zod";
|
|
276
|
+
function registerRemoveConnector(server, runtime, options) {
|
|
277
|
+
server.tool(
|
|
278
|
+
"remove_connector",
|
|
279
|
+
"Remove a connector from this Rawdash instance. For OSS, this is a runtime-only change. Idempotent \u2014 removing a non-existent connector returns success.",
|
|
280
|
+
{
|
|
281
|
+
connector_id: z4.string().describe("The connector instance ID to remove.")
|
|
282
|
+
},
|
|
283
|
+
async ({ connector_id }) => {
|
|
284
|
+
const existed = runtime.removeConnector(connector_id);
|
|
285
|
+
if (!existed) {
|
|
286
|
+
return text({ removed: connector_id, existed: false });
|
|
287
|
+
}
|
|
288
|
+
try {
|
|
289
|
+
await options.onRemoveConnector?.(connector_id);
|
|
290
|
+
} catch (e) {
|
|
291
|
+
return err(
|
|
292
|
+
"ON_REMOVE_CONNECTOR_FAILED",
|
|
293
|
+
`Connector removed in-memory but post-remove callback failed: ${e instanceof Error ? e.message : String(e)}`
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
return text({ removed: connector_id, existed: true });
|
|
297
|
+
}
|
|
298
|
+
);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// src/tools/render-widget.ts
|
|
302
|
+
import { computeMetric as computeMetric2 } from "@rawdash/server";
|
|
303
|
+
import { z as z5 } from "zod";
|
|
304
|
+
function renderStat(title, value) {
|
|
305
|
+
const display = typeof value === "number" ? value.toLocaleString("en-US", { maximumFractionDigits: 2 }) : String(value ?? "\u2014");
|
|
306
|
+
return `## ${title}
|
|
307
|
+
|
|
308
|
+
**${display}**
|
|
309
|
+
`;
|
|
310
|
+
}
|
|
311
|
+
function renderTimeseries(title, points) {
|
|
312
|
+
if (points.length === 0) {
|
|
313
|
+
return `## ${title}
|
|
314
|
+
|
|
315
|
+
_No data_
|
|
316
|
+
`;
|
|
317
|
+
}
|
|
318
|
+
const rows = points.map(
|
|
319
|
+
(p) => `| ${p.date} | ${typeof p.value === "number" ? p.value.toLocaleString("en-US", { maximumFractionDigits: 2 }) : String(p.value ?? "\u2014")} |`
|
|
320
|
+
).join("\n");
|
|
321
|
+
return `## ${title}
|
|
322
|
+
|
|
323
|
+
| Date | Value |
|
|
324
|
+
|------|-------|
|
|
325
|
+
${rows}
|
|
326
|
+
`;
|
|
327
|
+
}
|
|
328
|
+
function renderDistribution(title, value) {
|
|
329
|
+
return `## ${title}
|
|
330
|
+
|
|
331
|
+
\`\`\`json
|
|
332
|
+
${JSON.stringify(value, null, 2)}
|
|
333
|
+
\`\`\`
|
|
334
|
+
`;
|
|
335
|
+
}
|
|
336
|
+
function renderStatus(title, source, syncState) {
|
|
337
|
+
const statusEmoji = syncState.status === "idle" ? "\u2705" : syncState.status === "syncing" ? "\u{1F504}" : "\u274C";
|
|
338
|
+
const lastSync = syncState.lastSyncAt ? new Date(syncState.lastSyncAt).toUTCString() : "never";
|
|
339
|
+
return `## ${title}
|
|
340
|
+
|
|
341
|
+
${statusEmoji} **${syncState.status}** (connector: \`${source}\`)
|
|
342
|
+
|
|
343
|
+
Last sync: ${lastSync}${syncState.lastError ? `
|
|
344
|
+
|
|
345
|
+
Error: ${syncState.lastError}` : ""}
|
|
346
|
+
`;
|
|
347
|
+
}
|
|
348
|
+
function registerRenderWidget(server, runtime, storage) {
|
|
349
|
+
server.tool(
|
|
350
|
+
"render_widget",
|
|
351
|
+
"Render a widget as an inline artifact in the chat. Returns a formatted markdown representation of the widget data.",
|
|
352
|
+
{
|
|
353
|
+
dashboard_id: z5.string().describe("The dashboard ID."),
|
|
354
|
+
widget_id: z5.string().describe("The widget ID.")
|
|
355
|
+
},
|
|
356
|
+
async ({ dashboard_id, widget_id }) => {
|
|
357
|
+
try {
|
|
358
|
+
const dashboard = runtime.getDashboards()[dashboard_id];
|
|
359
|
+
if (!dashboard) {
|
|
360
|
+
return err("NOT_FOUND", `Dashboard "${dashboard_id}" not found`);
|
|
361
|
+
}
|
|
362
|
+
const widget = dashboard.widgets[widget_id];
|
|
363
|
+
if (!widget) {
|
|
364
|
+
return err("NOT_FOUND", `Widget "${widget_id}" not found`);
|
|
365
|
+
}
|
|
366
|
+
const syncState = await storage.getSyncState();
|
|
367
|
+
if (widget.kind === "status") {
|
|
368
|
+
return {
|
|
369
|
+
content: [
|
|
370
|
+
{
|
|
371
|
+
type: "text",
|
|
372
|
+
text: renderStatus(widget.title, widget.source, syncState)
|
|
373
|
+
}
|
|
374
|
+
]
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
const { connectorId } = widget.metric;
|
|
378
|
+
const connectorEntry = runtime.getConnectors().find((e) => e.connector.id === connectorId);
|
|
379
|
+
if (!connectorEntry) {
|
|
380
|
+
return err(
|
|
381
|
+
"CONNECTOR_NOT_FOUND",
|
|
382
|
+
`Connector "${connectorId}" not found`
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
const handle = storage.getStorageHandle(connectorId);
|
|
386
|
+
const data = await computeMetric2(handle, widget.metric);
|
|
387
|
+
let rendered;
|
|
388
|
+
if (widget.kind === "stat") {
|
|
389
|
+
rendered = renderStat(widget.title, data);
|
|
390
|
+
} else if (widget.kind === "timeseries") {
|
|
391
|
+
const points = Array.isArray(data) ? data : [];
|
|
392
|
+
rendered = renderTimeseries(widget.title, points);
|
|
393
|
+
} else if (widget.kind === "distribution") {
|
|
394
|
+
rendered = renderDistribution(widget.title, data);
|
|
395
|
+
} else {
|
|
396
|
+
rendered = `## ${widget.title}
|
|
397
|
+
|
|
398
|
+
\`\`\`json
|
|
399
|
+
${JSON.stringify(data, null, 2)}
|
|
400
|
+
\`\`\`
|
|
401
|
+
`;
|
|
402
|
+
}
|
|
403
|
+
const cachedNote = syncState.lastSyncAt ? `
|
|
404
|
+
_Cached at ${new Date(syncState.lastSyncAt).toUTCString()}_` : "\n_Not yet synced_";
|
|
405
|
+
return {
|
|
406
|
+
content: [{ type: "text", text: rendered + cachedNote }]
|
|
407
|
+
};
|
|
408
|
+
} catch (e) {
|
|
409
|
+
return err("RENDER_FAILED", e instanceof Error ? e.message : String(e));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// src/tools/set-secret.ts
|
|
416
|
+
import { z as z6 } from "zod";
|
|
417
|
+
var SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/;
|
|
418
|
+
function registerSetSecret(server, trackedSecrets, options) {
|
|
419
|
+
server.tool(
|
|
420
|
+
"set_secret",
|
|
421
|
+
"Set a secret for the running Rawdash instance. Secret names must be uppercase (e.g. GITHUB_TOKEN). For OSS, secrets are stored in process.env (runtime-only, not persisted).",
|
|
422
|
+
{
|
|
423
|
+
name: z6.string().describe(
|
|
424
|
+
"Secret name \u2014 uppercase letters, digits, and underscores; must start with a letter (e.g. GITHUB_TOKEN)."
|
|
425
|
+
),
|
|
426
|
+
value: z6.string().describe("The secret value.")
|
|
427
|
+
},
|
|
428
|
+
async ({ name, value }) => {
|
|
429
|
+
if (!SECRET_NAME_RE.test(name)) {
|
|
430
|
+
return err(
|
|
431
|
+
"INVALID_NAME",
|
|
432
|
+
`Secret name "${name}" is invalid. Must match /^[A-Z][A-Z0-9_]*$/.`
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
try {
|
|
436
|
+
if (options.onSetSecret) {
|
|
437
|
+
await options.onSetSecret(name, value);
|
|
438
|
+
} else {
|
|
439
|
+
const env = globalThis.process?.env;
|
|
440
|
+
if (!env) {
|
|
441
|
+
return err(
|
|
442
|
+
"NO_SECRET_BACKEND",
|
|
443
|
+
"No secret backend is configured for this runtime."
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
env[name] = value;
|
|
447
|
+
}
|
|
448
|
+
} catch (e) {
|
|
449
|
+
return err(
|
|
450
|
+
"SET_SECRET_FAILED",
|
|
451
|
+
e instanceof Error ? e.message : "Failed to set secret."
|
|
452
|
+
);
|
|
453
|
+
}
|
|
454
|
+
trackedSecrets.add(name);
|
|
455
|
+
return text({ set: name });
|
|
456
|
+
}
|
|
457
|
+
);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// src/tools/trigger-sync.ts
|
|
461
|
+
import { z as z7 } from "zod";
|
|
462
|
+
function registerTriggerSync(server, runtime, storage) {
|
|
463
|
+
server.tool(
|
|
464
|
+
"trigger_sync",
|
|
465
|
+
"Kick off a sync for one or all connectors. Runs in the background and returns immediately once started.",
|
|
466
|
+
{
|
|
467
|
+
connector_id: z7.string().optional().describe("Connector ID to sync. Omit to sync all connectors."),
|
|
468
|
+
mode: z7.enum(["full", "latest"]).optional().describe(
|
|
469
|
+
'"latest" (default) fetches only recent data. "full" re-fetches all historical data.'
|
|
470
|
+
)
|
|
471
|
+
},
|
|
472
|
+
async ({ connector_id, mode = "latest" }) => {
|
|
473
|
+
const connectors = runtime.getConnectors();
|
|
474
|
+
const targets = connector_id ? connectors.filter((e) => e.connector.id === connector_id) : connectors;
|
|
475
|
+
if (connector_id && targets.length === 0) {
|
|
476
|
+
return err("NOT_FOUND", `Connector "${connector_id}" not found`);
|
|
477
|
+
}
|
|
478
|
+
const acquired = await storage.setSyncing();
|
|
479
|
+
if (!acquired) {
|
|
480
|
+
return err("ALREADY_SYNCING", "A sync is already in progress");
|
|
481
|
+
}
|
|
482
|
+
const controller = new AbortController();
|
|
483
|
+
const run = async () => {
|
|
484
|
+
try {
|
|
485
|
+
for (const entry of targets) {
|
|
486
|
+
const handle = storage.getStorageHandle(entry.connector.id);
|
|
487
|
+
await entry.connector.sync(
|
|
488
|
+
{ mode: mode ?? "latest" },
|
|
489
|
+
handle,
|
|
490
|
+
controller.signal
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
await storage.setSyncSuccess();
|
|
494
|
+
} catch (e) {
|
|
495
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
496
|
+
try {
|
|
497
|
+
await storage.setSyncError(message);
|
|
498
|
+
} catch {
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
};
|
|
502
|
+
void run().catch(() => {
|
|
503
|
+
});
|
|
504
|
+
return text({
|
|
505
|
+
triggered: true,
|
|
506
|
+
connectors: targets.map((e) => e.connector.id),
|
|
507
|
+
mode
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/server.ts
|
|
514
|
+
function createMcpServer(options) {
|
|
515
|
+
const { name = "rawdash", version = "1.0.0", config, storage } = options;
|
|
516
|
+
const server = new McpServer({ name, version });
|
|
517
|
+
const runtime = new RuntimeConfig(config);
|
|
518
|
+
const trackedSecrets = /* @__PURE__ */ new Set();
|
|
519
|
+
registerListDashboards(server, runtime);
|
|
520
|
+
registerListWidgets(server, runtime);
|
|
521
|
+
registerReadWidget(server, runtime, storage);
|
|
522
|
+
registerRenderWidget(server, runtime, storage);
|
|
523
|
+
registerListConnectors(server, runtime, storage);
|
|
524
|
+
registerAddConnector(server, runtime, options);
|
|
525
|
+
registerRemoveConnector(server, runtime, options);
|
|
526
|
+
registerSetSecret(server, trackedSecrets, options);
|
|
527
|
+
registerListSecrets(server, trackedSecrets, options);
|
|
528
|
+
registerTriggerSync(server, runtime, storage);
|
|
529
|
+
return server;
|
|
530
|
+
}
|
|
531
|
+
export {
|
|
532
|
+
createMcpServer
|
|
533
|
+
};
|
|
534
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts","../src/runtime-config.ts","../src/tools/add-connector.ts","../src/tools/shared.ts","../src/tools/list-connectors.ts","../src/tools/list-dashboards.ts","../src/tools/list-secrets.ts","../src/tools/list-widgets.ts","../src/tools/read-widget.ts","../src/tools/remove-connector.ts","../src/tools/render-widget.ts","../src/tools/set-secret.ts","../src/tools/trigger-sync.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport { RuntimeConfig } from './runtime-config';\nimport { registerAddConnector } from './tools/add-connector';\nimport { registerListConnectors } from './tools/list-connectors';\nimport { registerListDashboards } from './tools/list-dashboards';\nimport { registerListSecrets } from './tools/list-secrets';\nimport { registerListWidgets } from './tools/list-widgets';\nimport { registerReadWidget } from './tools/read-widget';\nimport { registerRemoveConnector } from './tools/remove-connector';\nimport { registerRenderWidget } from './tools/render-widget';\nimport { registerSetSecret } from './tools/set-secret';\nimport { registerTriggerSync } from './tools/trigger-sync';\nimport type { McpServerOptions } from './types';\n\nexport function createMcpServer(options: McpServerOptions): McpServer {\n const { name = 'rawdash', version = '1.0.0', config, storage } = options;\n\n const server = new McpServer({ name, version });\n const runtime = new RuntimeConfig(config);\n const trackedSecrets = new Set<string>();\n\n registerListDashboards(server, runtime);\n registerListWidgets(server, runtime);\n registerReadWidget(server, runtime, storage);\n registerRenderWidget(server, runtime, storage);\n registerListConnectors(server, runtime, storage);\n registerAddConnector(server, runtime, options);\n registerRemoveConnector(server, runtime, options);\n registerSetSecret(server, trackedSecrets, options);\n registerListSecrets(server, trackedSecrets, options);\n registerTriggerSync(server, runtime, storage);\n\n return server;\n}\n","import type { ConnectorEntry, Dashboard, DashboardConfig } from '@rawdash/core';\n\nexport class RuntimeConfig {\n private connectors: ConnectorEntry[];\n private readonly dashboards: Record<string, Dashboard>;\n\n constructor(config: DashboardConfig) {\n this.connectors = [...config.connectors];\n this.dashboards = config.dashboards;\n }\n\n getConnectors(): ConnectorEntry[] {\n return [...this.connectors];\n }\n\n getDashboards(): Record<string, Dashboard> {\n return this.dashboards;\n }\n\n addConnector(entry: ConnectorEntry): void {\n if (this.connectors.some((e) => e.connector.id === entry.connector.id)) {\n throw new Error(`Connector \"${entry.connector.id}\" already exists`);\n }\n this.connectors = [...this.connectors, entry];\n }\n\n removeConnector(connectorId: string): boolean {\n const before = this.connectors.length;\n this.connectors = this.connectors.filter(\n (e) => e.connector.id !== connectorId,\n );\n return this.connectors.length < before;\n }\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerAddConnector(\n server: McpServer,\n runtime: RuntimeConfig,\n options: Pick<McpServerOptions, 'connectorFactories' | 'onAddConnector'>,\n): void {\n server.tool(\n 'add_connector',\n \"Add a connector instance to this Rawdash instance. Settings are validated against the connector's configFields schema. For OSS, this is a runtime-only change (not persisted to disk).\",\n {\n connector_type: z\n .string()\n .describe(\n 'The connector type ID (e.g. \"github-actions\"). Use list_connectors to see available types.',\n ),\n settings: z\n .record(z.string(), z.unknown())\n .describe(\n 'Connector settings as a JSON object. Schema depends on the connector type.',\n ),\n },\n async ({ connector_type, settings }) => {\n const factories = options.connectorFactories ?? [];\n const factory = factories.find((f) => f.id === connector_type);\n if (!factory) {\n const available = factories.map((f) => f.id);\n return err(\n 'UNKNOWN_CONNECTOR_TYPE',\n available.length > 0\n ? `Unknown connector type \"${connector_type}\". Available: ${available.join(', ')}`\n : `Unknown connector type \"${connector_type}\". No connector factories are registered.`,\n );\n }\n\n const parsed = factory.configFields.safeParse(settings);\n if (!parsed.success) {\n const issues = parsed.error.issues\n .map((i) => `${i.path.join('.')}: ${i.message}`)\n .join('; ');\n return err('INVALID_SETTINGS', `Invalid settings: ${issues}`);\n }\n\n let entry;\n try {\n entry = factory.create(parsed.data);\n } catch (e) {\n return err(\n 'CREATE_FAILED',\n `Failed to create connector: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n try {\n runtime.addConnector(entry);\n } catch (e) {\n return err(\n 'ALREADY_EXISTS',\n e instanceof Error ? e.message : String(e),\n );\n }\n\n try {\n await options.onAddConnector?.(entry);\n } catch (e) {\n return err(\n 'ON_ADD_CONNECTOR_FAILED',\n `Connector added in-memory but post-add callback failed: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n return text({ added: entry.connector.id, idempotent: false });\n },\n );\n}\n","function safeStringify(data: unknown): string {\n try {\n return JSON.stringify(\n data,\n (_key, value) => (typeof value === 'bigint' ? value.toString() : value),\n 2,\n );\n } catch {\n return JSON.stringify(\n {\n error: {\n code: 'SERIALIZATION_ERROR',\n message: 'Failed to serialize tool response',\n },\n },\n null,\n 2,\n );\n }\n}\n\nexport function text(data: unknown) {\n return {\n content: [{ type: 'text' as const, text: safeStringify(data) }],\n };\n}\n\nexport function err(code: string, message: string) {\n return text({ error: { code, message } });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerListConnectors(\n server: McpServer,\n runtime: RuntimeConfig,\n storage: McpServerOptions['storage'],\n): void {\n server.tool(\n 'list_connectors',\n 'List all configured connectors and their sync status.',\n {},\n async () => {\n try {\n const syncState = await storage.getSyncState();\n const connectors = runtime.getConnectors().map((entry) => ({\n id: entry.connector.id,\n syncStatus: syncState.status,\n lastSyncAt: syncState.lastSyncAt,\n lastError: syncState.lastError,\n hasCredentials:\n Object.keys(entry.connector.credentials ?? {}).length > 0,\n credentialKeys: Object.keys(entry.connector.credentials ?? {}),\n }));\n return text({ connectors, overallSyncStatus: syncState.status });\n } catch (e) {\n return err(\n 'LIST_CONNECTORS_FAILED',\n e instanceof Error ? e.message : String(e),\n );\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport { text } from './shared';\n\nexport function registerListDashboards(\n server: McpServer,\n runtime: RuntimeConfig,\n): void {\n server.tool(\n 'list_dashboards',\n 'List all dashboards available on this Rawdash instance.',\n {},\n () => {\n const dashboards = Object.entries(runtime.getDashboards()).map(\n ([id, dashboard]) => ({\n id,\n widgetCount: Object.keys(dashboard.widgets).length,\n widgetIds: Object.keys(dashboard.widgets),\n }),\n );\n return Promise.resolve(text({ dashboards }));\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\n\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerListSecrets(\n server: McpServer,\n trackedSecrets: Set<string>,\n options: Pick<McpServerOptions, 'listSecrets'>,\n): void {\n server.tool(\n 'list_secrets',\n 'List secret names known to this Rawdash instance. Values are never returned.',\n {},\n async () => {\n try {\n const names = options.listSecrets\n ? await options.listSecrets()\n : [...trackedSecrets];\n return text({ secrets: [...names].sort() });\n } catch (e) {\n return err(\n 'LIST_SECRETS_FAILED',\n e instanceof Error ? e.message : 'Failed to list secrets.',\n );\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport { err, text } from './shared';\n\nexport function registerListWidgets(\n server: McpServer,\n runtime: RuntimeConfig,\n): void {\n server.tool(\n 'list_widgets',\n 'List all widgets on a dashboard.',\n {\n dashboard_id: z\n .string()\n .describe('The dashboard ID to list widgets for.'),\n },\n ({ dashboard_id }) => {\n const dashboard = runtime.getDashboards()[dashboard_id];\n if (!dashboard) {\n return Promise.resolve(\n err('NOT_FOUND', `Dashboard \"${dashboard_id}\" not found`),\n );\n }\n const widgets = Object.entries(dashboard.widgets).map(([id, widget]) => ({\n id,\n kind: widget.kind,\n title: widget.title,\n ...(widget.kind !== 'status'\n ? { connectorId: widget.metric.connectorId }\n : { source: widget.source }),\n }));\n return Promise.resolve(text({ dashboard_id, widgets }));\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { computeMetric } from '@rawdash/server';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerReadWidget(\n server: McpServer,\n runtime: RuntimeConfig,\n storage: McpServerOptions['storage'],\n): void {\n server.tool(\n 'read_widget',\n 'Fetch resolved widget data. Returns the same shape as the HTTP read API.',\n {\n dashboard_id: z.string().describe('The dashboard ID.'),\n widget_id: z.string().describe('The widget ID.'),\n },\n async ({ dashboard_id, widget_id }) => {\n try {\n const dashboard = runtime.getDashboards()[dashboard_id];\n if (!dashboard) {\n return err('NOT_FOUND', `Dashboard \"${dashboard_id}\" not found`);\n }\n const widget = dashboard.widgets[widget_id];\n if (!widget) {\n return err('NOT_FOUND', `Widget \"${widget_id}\" not found`);\n }\n\n if (widget.kind === 'status') {\n const syncState = await storage.getSyncState();\n return text({\n id: widget_id,\n widgetId: widget_id,\n connectorId: widget.source,\n data: null,\n cachedAt: syncState.lastSyncAt,\n });\n }\n\n const { connectorId } = widget.metric;\n const connectorEntry = runtime\n .getConnectors()\n .find((e) => e.connector.id === connectorId);\n if (!connectorEntry) {\n return err(\n 'CONNECTOR_NOT_FOUND',\n `Connector \"${connectorId}\" not found`,\n );\n }\n\n const handle = storage.getStorageHandle(connectorId);\n const data = await computeMetric(handle, widget.metric);\n const syncState = await storage.getSyncState();\n\n return text({\n id: widget_id,\n widgetId: widget_id,\n connectorId,\n data,\n cachedAt: syncState.lastSyncAt,\n });\n } catch (e) {\n return err('READ_FAILED', e instanceof Error ? e.message : String(e));\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerRemoveConnector(\n server: McpServer,\n runtime: RuntimeConfig,\n options: Pick<McpServerOptions, 'onRemoveConnector'>,\n): void {\n server.tool(\n 'remove_connector',\n 'Remove a connector from this Rawdash instance. For OSS, this is a runtime-only change. Idempotent — removing a non-existent connector returns success.',\n {\n connector_id: z.string().describe('The connector instance ID to remove.'),\n },\n async ({ connector_id }) => {\n const existed = runtime.removeConnector(connector_id);\n if (!existed) {\n return text({ removed: connector_id, existed: false });\n }\n\n try {\n await options.onRemoveConnector?.(connector_id);\n } catch (e) {\n return err(\n 'ON_REMOVE_CONNECTOR_FAILED',\n `Connector removed in-memory but post-remove callback failed: ${e instanceof Error ? e.message : String(e)}`,\n );\n }\n\n return text({ removed: connector_id, existed: true });\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { computeMetric } from '@rawdash/server';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err } from './shared';\n\nfunction renderStat(title: string, value: unknown): string {\n const display =\n typeof value === 'number'\n ? value.toLocaleString('en-US', { maximumFractionDigits: 2 })\n : String(value ?? '—');\n return `## ${title}\\n\\n**${display}**\\n`;\n}\n\nfunction renderTimeseries(\n title: string,\n points: Array<{ date: string; value: unknown }>,\n): string {\n if (points.length === 0) {\n return `## ${title}\\n\\n_No data_\\n`;\n }\n const rows = points\n .map(\n (p) =>\n `| ${p.date} | ${typeof p.value === 'number' ? p.value.toLocaleString('en-US', { maximumFractionDigits: 2 }) : String(p.value ?? '—')} |`,\n )\n .join('\\n');\n return `## ${title}\\n\\n| Date | Value |\\n|------|-------|\\n${rows}\\n`;\n}\n\nfunction renderDistribution(title: string, value: unknown): string {\n return `## ${title}\\n\\n\\`\\`\\`json\\n${JSON.stringify(value, null, 2)}\\n\\`\\`\\`\\n`;\n}\n\nfunction renderStatus(\n title: string,\n source: string,\n syncState: {\n status: string;\n lastSyncAt: string | null;\n lastError: string | null;\n },\n): string {\n const statusEmoji =\n syncState.status === 'idle'\n ? '✅'\n : syncState.status === 'syncing'\n ? '🔄'\n : '❌';\n const lastSync = syncState.lastSyncAt\n ? new Date(syncState.lastSyncAt).toUTCString()\n : 'never';\n return `## ${title}\\n\\n${statusEmoji} **${syncState.status}** (connector: \\`${source}\\`)\\n\\nLast sync: ${lastSync}${syncState.lastError ? `\\n\\nError: ${syncState.lastError}` : ''}\\n`;\n}\n\nexport function registerRenderWidget(\n server: McpServer,\n runtime: RuntimeConfig,\n storage: McpServerOptions['storage'],\n): void {\n server.tool(\n 'render_widget',\n 'Render a widget as an inline artifact in the chat. Returns a formatted markdown representation of the widget data.',\n {\n dashboard_id: z.string().describe('The dashboard ID.'),\n widget_id: z.string().describe('The widget ID.'),\n },\n async ({ dashboard_id, widget_id }) => {\n try {\n const dashboard = runtime.getDashboards()[dashboard_id];\n if (!dashboard) {\n return err('NOT_FOUND', `Dashboard \"${dashboard_id}\" not found`);\n }\n const widget = dashboard.widgets[widget_id];\n if (!widget) {\n return err('NOT_FOUND', `Widget \"${widget_id}\" not found`);\n }\n\n const syncState = await storage.getSyncState();\n\n if (widget.kind === 'status') {\n return {\n content: [\n {\n type: 'text' as const,\n text: renderStatus(widget.title, widget.source, syncState),\n },\n ],\n };\n }\n\n const { connectorId } = widget.metric;\n const connectorEntry = runtime\n .getConnectors()\n .find((e) => e.connector.id === connectorId);\n if (!connectorEntry) {\n return err(\n 'CONNECTOR_NOT_FOUND',\n `Connector \"${connectorId}\" not found`,\n );\n }\n\n const handle = storage.getStorageHandle(connectorId);\n const data = await computeMetric(handle, widget.metric);\n\n let rendered: string;\n\n if (widget.kind === 'stat') {\n rendered = renderStat(widget.title, data);\n } else if (widget.kind === 'timeseries') {\n const points = Array.isArray(data)\n ? (data as Array<{ date: string; value: unknown }>)\n : [];\n rendered = renderTimeseries(widget.title, points);\n } else if (widget.kind === 'distribution') {\n rendered = renderDistribution(widget.title, data);\n } else {\n rendered = `## ${(widget as { title: string }).title}\\n\\n\\`\\`\\`json\\n${JSON.stringify(data, null, 2)}\\n\\`\\`\\`\\n`;\n }\n\n const cachedNote = syncState.lastSyncAt\n ? `\\n_Cached at ${new Date(syncState.lastSyncAt).toUTCString()}_`\n : '\\n_Not yet synced_';\n\n return {\n content: [{ type: 'text' as const, text: rendered + cachedNote }],\n };\n } catch (e) {\n return err('RENDER_FAILED', e instanceof Error ? e.message : String(e));\n }\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { z } from 'zod';\n\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nconst SECRET_NAME_RE = /^[A-Z][A-Z0-9_]*$/;\n\nexport function registerSetSecret(\n server: McpServer,\n trackedSecrets: Set<string>,\n options: Pick<McpServerOptions, 'onSetSecret'>,\n): void {\n server.tool(\n 'set_secret',\n 'Set a secret for the running Rawdash instance. Secret names must be uppercase (e.g. GITHUB_TOKEN). For OSS, secrets are stored in process.env (runtime-only, not persisted).',\n {\n name: z\n .string()\n .describe(\n 'Secret name — uppercase letters, digits, and underscores; must start with a letter (e.g. GITHUB_TOKEN).',\n ),\n value: z.string().describe('The secret value.'),\n },\n async ({ name, value }) => {\n if (!SECRET_NAME_RE.test(name)) {\n return err(\n 'INVALID_NAME',\n `Secret name \"${name}\" is invalid. Must match /^[A-Z][A-Z0-9_]*$/.`,\n );\n }\n\n try {\n if (options.onSetSecret) {\n await options.onSetSecret(name, value);\n } else {\n const env = (\n globalThis as {\n process?: { env?: Record<string, string | undefined> };\n }\n ).process?.env;\n if (!env) {\n return err(\n 'NO_SECRET_BACKEND',\n 'No secret backend is configured for this runtime.',\n );\n }\n env[name] = value;\n }\n } catch (e) {\n return err(\n 'SET_SECRET_FAILED',\n e instanceof Error ? e.message : 'Failed to set secret.',\n );\n }\n\n trackedSecrets.add(name);\n\n return text({ set: name });\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp';\nimport { z } from 'zod';\n\nimport type { RuntimeConfig } from '../runtime-config';\nimport type { McpServerOptions } from '../types';\nimport { err, text } from './shared';\n\nexport function registerTriggerSync(\n server: McpServer,\n runtime: RuntimeConfig,\n storage: McpServerOptions['storage'],\n): void {\n server.tool(\n 'trigger_sync',\n 'Kick off a sync for one or all connectors. Runs in the background and returns immediately once started.',\n {\n connector_id: z\n .string()\n .optional()\n .describe('Connector ID to sync. Omit to sync all connectors.'),\n mode: z\n .enum(['full', 'latest'])\n .optional()\n .describe(\n '\"latest\" (default) fetches only recent data. \"full\" re-fetches all historical data.',\n ),\n },\n async ({ connector_id, mode = 'latest' }) => {\n const connectors = runtime.getConnectors();\n const targets = connector_id\n ? connectors.filter((e) => e.connector.id === connector_id)\n : connectors;\n\n if (connector_id && targets.length === 0) {\n return err('NOT_FOUND', `Connector \"${connector_id}\" not found`);\n }\n\n const acquired = await storage.setSyncing();\n if (!acquired) {\n return err('ALREADY_SYNCING', 'A sync is already in progress');\n }\n\n const controller = new AbortController();\n\n const run = async () => {\n try {\n for (const entry of targets) {\n const handle = storage.getStorageHandle(entry.connector.id);\n await entry.connector.sync(\n { mode: mode ?? 'latest' },\n handle,\n controller.signal,\n );\n }\n await storage.setSyncSuccess();\n } catch (e) {\n const message = e instanceof Error ? e.message : String(e);\n try {\n await storage.setSyncError(message);\n } catch {\n // Intentionally swallow to avoid unhandled background rejection.\n }\n }\n };\n\n void run().catch(() => {\n // Defensive terminal catch for any unexpected rejection path.\n });\n\n return text({\n triggered: true,\n connectors: targets.map((e) => e.connector.id),\n mode,\n });\n },\n );\n}\n"],"mappings":";AAAA,SAAS,iBAAiB;;;ACEnB,IAAM,gBAAN,MAAoB;AAAA,EACjB;AAAA,EACS;AAAA,EAEjB,YAAY,QAAyB;AACnC,SAAK,aAAa,CAAC,GAAG,OAAO,UAAU;AACvC,SAAK,aAAa,OAAO;AAAA,EAC3B;AAAA,EAEA,gBAAkC;AAChC,WAAO,CAAC,GAAG,KAAK,UAAU;AAAA,EAC5B;AAAA,EAEA,gBAA2C;AACzC,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,aAAa,OAA6B;AACxC,QAAI,KAAK,WAAW,KAAK,CAAC,MAAM,EAAE,UAAU,OAAO,MAAM,UAAU,EAAE,GAAG;AACtE,YAAM,IAAI,MAAM,cAAc,MAAM,UAAU,EAAE,kBAAkB;AAAA,IACpE;AACA,SAAK,aAAa,CAAC,GAAG,KAAK,YAAY,KAAK;AAAA,EAC9C;AAAA,EAEA,gBAAgB,aAA8B;AAC5C,UAAM,SAAS,KAAK,WAAW;AAC/B,SAAK,aAAa,KAAK,WAAW;AAAA,MAChC,CAAC,MAAM,EAAE,UAAU,OAAO;AAAA,IAC5B;AACA,WAAO,KAAK,WAAW,SAAS;AAAA,EAClC;AACF;;;AChCA,SAAS,SAAS;;;ACDlB,SAAS,cAAc,MAAuB;AAC5C,MAAI;AACF,WAAO,KAAK;AAAA,MACV;AAAA,MACA,CAAC,MAAM,UAAW,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI;AAAA,MACjE;AAAA,IACF;AAAA,EACF,QAAQ;AACN,WAAO,KAAK;AAAA,MACV;AAAA,QACE,OAAO;AAAA,UACL,MAAM;AAAA,UACN,SAAS;AAAA,QACX;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACF;AAEO,SAAS,KAAK,MAAe;AAClC,SAAO;AAAA,IACL,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,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,QAAQ,SAAS,OAAO;AAC7C,yBAAuB,QAAQ,SAAS,OAAO;AAC/C,uBAAqB,QAAQ,SAAS,OAAO;AAC7C,0BAAwB,QAAQ,SAAS,OAAO;AAChD,oBAAkB,QAAQ,gBAAgB,OAAO;AACjD,sBAAoB,QAAQ,gBAAgB,OAAO;AACnD,sBAAoB,QAAQ,SAAS,OAAO;AAE5C,SAAO;AACT;","names":["z","z","z","z","syncState","z","z","computeMetric","z","z","computeMetric","z","z","z","z"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rawdash/mcp",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Rawdash MCP server — exposes dashboards, widgets, and connectors to AI agents",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/rawdash/rawdash.git",
|
|
10
|
+
"directory": "packages/mcp"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"README.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"@rawdash/source": "./src/index.ts",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
26
|
+
"zod": "^4.4.3",
|
|
27
|
+
"@rawdash/server": "0.1.0",
|
|
28
|
+
"@rawdash/core": "0.1.0"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"tsup": "^8.0.0",
|
|
32
|
+
"typescript": "^5.7.2"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsup",
|
|
36
|
+
"typecheck": "tsc --noEmit",
|
|
37
|
+
"lint": "eslint src",
|
|
38
|
+
"test": "vitest run"
|
|
39
|
+
}
|
|
40
|
+
}
|