@schemyx/mcp 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -2
- package/dist/backend-client.d.ts +1 -17
- package/dist/backend-client.js +15 -91
- package/dist/backend-client.js.map +1 -1
- package/dist/client/backend-client.d.ts +17 -0
- package/dist/client/backend-client.js +97 -0
- package/dist/client/backend-client.js.map +1 -0
- package/dist/client/local-theme-source.d.ts +19 -0
- package/dist/client/local-theme-source.js +737 -0
- package/dist/client/local-theme-source.js.map +1 -0
- package/dist/client/mcp-client.d.ts +15 -0
- package/dist/client/mcp-client.js +46 -0
- package/dist/client/mcp-client.js.map +1 -0
- package/dist/codebase-scanner/backend.d.ts +12 -0
- package/dist/codebase-scanner/backend.js +814 -0
- package/dist/codebase-scanner/backend.js.map +1 -0
- package/dist/codebase-scanner/bundle.d.ts +81 -0
- package/dist/codebase-scanner/bundle.js +2177 -0
- package/dist/codebase-scanner/bundle.js.map +1 -0
- package/dist/codebase-scanner/constants.d.ts +26 -0
- package/dist/codebase-scanner/constants.js +230 -0
- package/dist/codebase-scanner/constants.js.map +1 -0
- package/dist/codebase-scanner/extractors.d.ts +187 -0
- package/dist/codebase-scanner/extractors.js +2600 -0
- package/dist/codebase-scanner/extractors.js.map +1 -0
- package/dist/codebase-scanner/files.d.ts +16 -0
- package/dist/codebase-scanner/files.js +233 -0
- package/dist/codebase-scanner/files.js.map +1 -0
- package/dist/codebase-scanner/index.d.ts +217 -0
- package/dist/codebase-scanner/index.js +387 -0
- package/dist/codebase-scanner/index.js.map +1 -0
- package/dist/codebase-scanner/recipes.d.ts +74 -0
- package/dist/codebase-scanner/recipes.js +585 -0
- package/dist/codebase-scanner/recipes.js.map +1 -0
- package/dist/codebase-scanner/storage.d.ts +19 -0
- package/dist/codebase-scanner/storage.js +103 -0
- package/dist/codebase-scanner/storage.js.map +1 -0
- package/dist/codebase-scanner/types.d.ts +522 -0
- package/dist/codebase-scanner/types.js +3 -0
- package/dist/codebase-scanner/types.js.map +1 -0
- package/dist/codebase-scanner/utils.d.ts +37 -0
- package/dist/codebase-scanner/utils.js +259 -0
- package/dist/codebase-scanner/utils.js.map +1 -0
- package/dist/codebase-scanner.d.ts +1 -0
- package/dist/codebase-scanner.js +18 -0
- package/dist/codebase-scanner.js.map +1 -0
- package/dist/config.d.ts +1 -2
- package/dist/config.js +15 -37
- package/dist/config.js.map +1 -1
- package/dist/local-theme-source.d.ts +1 -0
- package/dist/local-theme-source.js +18 -0
- package/dist/local-theme-source.js.map +1 -0
- package/dist/main.js +3 -3
- package/dist/main.js.map +1 -1
- package/dist/mcp-client.d.ts +1 -0
- package/dist/mcp-client.js +18 -0
- package/dist/mcp-client.js.map +1 -0
- package/dist/prompts.d.ts +1 -7
- package/dist/prompts.js +15 -52
- package/dist/prompts.js.map +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js +163 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/prompts.d.ts +7 -0
- package/dist/server/prompts.js +55 -0
- package/dist/server/prompts.js.map +1 -0
- package/dist/server/tool-definitions.d.ts +22 -0
- package/dist/server/tool-definitions.js +531 -0
- package/dist/server/tool-definitions.js.map +1 -0
- package/dist/server.d.ts +3 -3
- package/dist/server.js +33 -0
- package/dist/server.js.map +1 -1
- package/dist/shared/config.d.ts +2 -0
- package/dist/shared/config.js +54 -0
- package/dist/shared/config.js.map +1 -0
- package/dist/shared/text.d.ts +14 -0
- package/dist/shared/text.js +33 -0
- package/dist/shared/text.js.map +1 -0
- package/dist/shared/types.d.ts +118 -0
- package/dist/shared/types.js +3 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/shared/uri.d.ts +6 -0
- package/dist/shared/uri.js +24 -0
- package/dist/shared/uri.js.map +1 -0
- package/dist/style-recipes.d.ts +1 -0
- package/dist/style-recipes.js +18 -0
- package/dist/style-recipes.js.map +1 -0
- package/dist/text.d.ts +1 -14
- package/dist/text.js +15 -30
- package/dist/text.js.map +1 -1
- package/dist/theme/style-recipes.d.ts +26 -0
- package/dist/theme/style-recipes.js +129 -0
- package/dist/theme/style-recipes.js.map +1 -0
- package/dist/tool-definitions.d.ts +1 -11
- package/dist/tool-definitions.js +15 -127
- package/dist/tool-definitions.js.map +1 -1
- package/dist/types.d.ts +1 -106
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -1
- package/dist/uri.d.ts +1 -6
- package/dist/uri.js +15 -21
- package/dist/uri.js.map +1 -1
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -2,8 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Local stdio MCP server for reading Schemyx project configs, Theme Forge artifacts, target-stack guidance, and implementation notes.
|
|
4
4
|
|
|
5
|
+
The server supports both local theme files and hosted Schemyx configs. By default it checks for local files first, then falls back to the hosted Schemyx API.
|
|
6
|
+
|
|
5
7
|
## Usage
|
|
6
8
|
|
|
9
|
+
Local files only:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# From a repo that contains ./schemyx-ui-theme/themeforge.json
|
|
13
|
+
npx -y @schemyx/mcp
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Hosted Schemyx:
|
|
17
|
+
|
|
7
18
|
```bash
|
|
8
19
|
SCHEMYX_API_KEY=skx_live_replace_me npx -y @schemyx/mcp
|
|
9
20
|
```
|
|
@@ -26,11 +37,74 @@ MCP client config:
|
|
|
26
37
|
|
|
27
38
|
## Environment
|
|
28
39
|
|
|
29
|
-
- `SCHEMYX_API_KEY`:
|
|
40
|
+
- `SCHEMYX_API_KEY`: Schemyx API key with `mcp:read` or `configs:read`; required only when using hosted configs
|
|
30
41
|
- `SCHEMYX_API_URL`: optional API base URL, defaults to `https://api.schemyx.com`
|
|
31
42
|
- `SCHEMYX_PROJECT_ID`: optional project filter
|
|
32
43
|
- `SCHEMYX_CONFIG_ID`: optional config filter
|
|
33
44
|
- `SCHEMYX_MCP_CACHE_TTL_MS`: optional discovery cache TTL, defaults to `10000`
|
|
45
|
+
- `SCHEMYX_MCP_SOURCE`: optional source mode, `auto`, `local`, or `remote`; defaults to `auto`
|
|
46
|
+
- `SCHEMYX_THEME_DIR`: optional local theme directory containing `themeforge.json`
|
|
47
|
+
- `SCHEMYX_MCP_CWD`: optional cwd used for local theme discovery
|
|
48
|
+
|
|
49
|
+
## Local Theme Discovery
|
|
50
|
+
|
|
51
|
+
In `auto` mode, the MCP server searches upward from the current working directory and uses the first local theme it finds:
|
|
52
|
+
|
|
53
|
+
1. `./schemyx-ui-theme/themeforge.json`
|
|
54
|
+
2. `./.schemyx/theme/themeforge.json`
|
|
55
|
+
3. `./themeforge.json`
|
|
56
|
+
|
|
57
|
+
If none exists, it uses the hosted API.
|
|
58
|
+
|
|
59
|
+
Local discovery exposes the compact style index (`agent-style-index.json`), agent style contract (`agent-style-contract.json`), standard Theme Forge files, all current target-stack artifacts (`tailwind-theme.css`, `shadcn-globals.css`, `mui-theme.ts`, `chakra-system.ts`, `mantine-theme.ts`, `styled-theme.ts`, `theme.scss`, `tokens.json`, `react-native-theme.ts`), stack helper files placed next to `themeforge.json` such as `components.json` or `tailwind.config.ts`, and any extra safe relative paths listed in `schemyx-theme-bundle.manifest.json`.
|
|
60
|
+
|
|
61
|
+
For targeted lookup, use `schemyx_list_style_recipes` and `schemyx_get_style_recipe`. Example: `schemyx_get_style_recipe` with `{ "key": "ui.input" }` returns only the input recipe and direct dependencies.
|
|
62
|
+
|
|
63
|
+
## Local Codebase Scan
|
|
64
|
+
|
|
65
|
+
The MCP package can also build local-only codebase configs for agents. This does **not** upload source files to Schemyx. The MCP server reads files from the customer's machine and writes compact generated files back into the repo:
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
.schemyx/codebase/
|
|
69
|
+
manifest.json
|
|
70
|
+
codebase-guide.md
|
|
71
|
+
graph/
|
|
72
|
+
nodes.jsonl
|
|
73
|
+
edges.jsonl
|
|
74
|
+
index/
|
|
75
|
+
aliases.json
|
|
76
|
+
terms.json
|
|
77
|
+
groups.json
|
|
78
|
+
recipes/
|
|
79
|
+
component.jsonl
|
|
80
|
+
route.jsonl
|
|
81
|
+
api.jsonl
|
|
82
|
+
service.jsonl
|
|
83
|
+
model.jsonl
|
|
84
|
+
style.jsonl
|
|
85
|
+
cluster.jsonl
|
|
86
|
+
rule.jsonl
|
|
87
|
+
review/
|
|
88
|
+
items.json
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Use `schemyx_scan_codebase` with an explicit scope:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{
|
|
95
|
+
"projectType": "frontend",
|
|
96
|
+
"includePaths": ["src/app", "src/components", "package.json"]
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Supported `projectType` values:
|
|
101
|
+
|
|
102
|
+
- `frontend`: routes, UI components, hooks, styles, template UI elements, and frontend config
|
|
103
|
+
- `backend`: controllers, services, modules, API routes, Prisma/SQL/ORM models, and backend config
|
|
104
|
+
- `full`: scans the repo with safe ignores like `node_modules`, `.next`, `dist`, and `.git`
|
|
105
|
+
- `custom`: scans only `includePaths`; use this when the user picked exact files
|
|
106
|
+
|
|
107
|
+
The output is a segmented universal graph plus grouped keyed recipes. The scanner produces broad baseline coverage for TypeScript/JavaScript, React, Next.js, NestJS, Prisma, CSS/Tailwind, raw HTML/templates, PHP/Laravel-style apps, SQL schemas, docs, tests, configs, and common package manifests. After scanning, use `schemyx_search_codebase`, `schemyx_get_codebase_recipe`, `schemyx_get_context_pack`, `schemyx_get_codebase_graph`, `schemyx_list_review_items`, `schemyx_check_context_freshness`, and `schemyx_read_codebase_file`.
|
|
34
108
|
|
|
35
109
|
## Development
|
|
36
110
|
|
|
@@ -38,7 +112,7 @@ From the backend repo root:
|
|
|
38
112
|
|
|
39
113
|
```bash
|
|
40
114
|
npm run build:mcp
|
|
41
|
-
SCHEMYX_API_URL=http://localhost:
|
|
115
|
+
SCHEMYX_API_URL=http://localhost:3001 \
|
|
42
116
|
SCHEMYX_API_KEY=skx_test_replace_me \
|
|
43
117
|
npm run mcp:local
|
|
44
118
|
```
|
package/dist/backend-client.d.ts
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare class SchemyxBackendClient {
|
|
3
|
-
private readonly config;
|
|
4
|
-
private contextCache;
|
|
5
|
-
private manifestCache;
|
|
6
|
-
constructor(config: LocalMcpConfig);
|
|
7
|
-
getContext(): Promise<McpContextResponse>;
|
|
8
|
-
listConfigs(): Promise<McpConfigResponse[]>;
|
|
9
|
-
discoverConfigs(): Promise<DiscoveredConfig[]>;
|
|
10
|
-
getManifest(configId: string): Promise<BackendConfigManifest>;
|
|
11
|
-
getLatestConfig(configId: string): Promise<McpConfigResponse>;
|
|
12
|
-
readResource(configId: string, resourceId: string): Promise<BackendResourceContent>;
|
|
13
|
-
executeTool(configId: string, toolName: string, args: Record<string, unknown>): Promise<BackendToolResult>;
|
|
14
|
-
resolveConfigId(configId: string | undefined): Promise<string>;
|
|
15
|
-
private request;
|
|
16
|
-
private cacheEntry;
|
|
17
|
-
}
|
|
1
|
+
export * from './client/backend-client';
|
package/dist/backend-client.js
CHANGED
|
@@ -1,94 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports
|
|
4
|
-
class SchemyxBackendClient {
|
|
5
|
-
config;
|
|
6
|
-
contextCache = null;
|
|
7
|
-
manifestCache = new Map();
|
|
8
|
-
constructor(config) {
|
|
9
|
-
this.config = config;
|
|
10
|
-
}
|
|
11
|
-
async getContext() {
|
|
12
|
-
const cached = this.contextCache;
|
|
13
|
-
if (cached && cached.expiresAt > Date.now()) {
|
|
14
|
-
return cached.value;
|
|
15
|
-
}
|
|
16
|
-
const value = await this.request('/mcp/context');
|
|
17
|
-
this.contextCache = this.cacheEntry(value);
|
|
18
|
-
return value;
|
|
19
|
-
}
|
|
20
|
-
async listConfigs() {
|
|
21
|
-
const context = await this.getContext();
|
|
22
|
-
const configs = context.projects
|
|
23
|
-
.filter((project) => !this.config.projectId || project.id === this.config.projectId)
|
|
24
|
-
.flatMap((project) => project.configs);
|
|
25
|
-
if (this.config.configId) {
|
|
26
|
-
return configs.filter((config) => config.id === this.config.configId);
|
|
27
|
-
}
|
|
28
|
-
return configs;
|
|
29
|
-
}
|
|
30
|
-
async discoverConfigs() {
|
|
31
|
-
const configs = await this.listConfigs();
|
|
32
|
-
return Promise.all(configs.map(async (config) => ({
|
|
33
|
-
config,
|
|
34
|
-
manifest: await this.getManifest(config.id),
|
|
35
|
-
})));
|
|
36
|
-
}
|
|
37
|
-
async getManifest(configId) {
|
|
38
|
-
const cached = this.manifestCache.get(configId);
|
|
39
|
-
if (cached && cached.expiresAt > Date.now()) {
|
|
40
|
-
return cached.value;
|
|
41
|
-
}
|
|
42
|
-
const value = await this.request(`/mcp/configs/${configId}/manifest`);
|
|
43
|
-
this.manifestCache.set(configId, this.cacheEntry(value));
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
async getLatestConfig(configId) {
|
|
47
|
-
return this.request(`/mcp/configs/${configId}/latest`);
|
|
48
|
-
}
|
|
49
|
-
async readResource(configId, resourceId) {
|
|
50
|
-
return this.request(`/mcp/configs/${configId}/resources/${encodeURIComponent(resourceId)}`);
|
|
51
|
-
}
|
|
52
|
-
async executeTool(configId, toolName, args) {
|
|
53
|
-
return this.request(`/mcp/configs/${configId}/tools/${encodeURIComponent(toolName)}`, {
|
|
54
|
-
method: 'POST',
|
|
55
|
-
body: JSON.stringify({ arguments: args }),
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
async resolveConfigId(configId) {
|
|
59
|
-
if (configId) {
|
|
60
|
-
return configId;
|
|
61
|
-
}
|
|
62
|
-
const configs = await this.listConfigs();
|
|
63
|
-
if (configs.length === 1) {
|
|
64
|
-
return configs[0].id;
|
|
65
|
-
}
|
|
66
|
-
if (configs.length === 0) {
|
|
67
|
-
throw new Error('No Schemyx configs are available for this API key.');
|
|
68
|
-
}
|
|
69
|
-
throw new Error('Multiple configs are available. Pass configId to choose one.');
|
|
70
|
-
}
|
|
71
|
-
async request(path, init) {
|
|
72
|
-
const response = await fetch(`${this.config.apiUrl}${path}`, {
|
|
73
|
-
...init,
|
|
74
|
-
headers: {
|
|
75
|
-
Accept: 'application/json',
|
|
76
|
-
Authorization: `Bearer ${this.config.apiKey}`,
|
|
77
|
-
...(init?.body ? { 'Content-Type': 'application/json' } : {}),
|
|
78
|
-
...init?.headers,
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
if (!response.ok) {
|
|
82
|
-
throw new Error(`Schemyx API request failed: ${response.status} ${response.statusText} ${await response.text()}`);
|
|
83
|
-
}
|
|
84
|
-
return (await response.json());
|
|
85
|
-
}
|
|
86
|
-
cacheEntry(value) {
|
|
87
|
-
return {
|
|
88
|
-
expiresAt: Date.now() + this.config.cacheTtlMs,
|
|
89
|
-
value,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
exports.SchemyxBackendClient = SchemyxBackendClient;
|
|
17
|
+
__exportStar(require("./client/backend-client"), exports);
|
|
94
18
|
//# sourceMappingURL=backend-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend-client.js","sourceRoot":"","sources":["../src/backend-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"backend-client.js","sourceRoot":"","sources":["../src/backend-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAwC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BackendConfigManifest, BackendResourceContent, BackendToolResult, DiscoveredConfig, LocalMcpConfig, McpConfigResponse, McpContextResponse, SchemyxMcpSource } from '../shared/types';
|
|
2
|
+
export declare class SchemyxBackendClient implements SchemyxMcpSource {
|
|
3
|
+
private readonly config;
|
|
4
|
+
private contextCache;
|
|
5
|
+
private manifestCache;
|
|
6
|
+
constructor(config: LocalMcpConfig);
|
|
7
|
+
getContext(): Promise<McpContextResponse>;
|
|
8
|
+
listConfigs(): Promise<McpConfigResponse[]>;
|
|
9
|
+
discoverConfigs(): Promise<DiscoveredConfig[]>;
|
|
10
|
+
getManifest(configId: string): Promise<BackendConfigManifest>;
|
|
11
|
+
getLatestConfig(configId: string): Promise<McpConfigResponse>;
|
|
12
|
+
readResource(configId: string, resourceId: string): Promise<BackendResourceContent>;
|
|
13
|
+
executeTool(configId: string, toolName: string, args: Record<string, unknown>): Promise<BackendToolResult>;
|
|
14
|
+
resolveConfigId(configId: string | undefined): Promise<string>;
|
|
15
|
+
private request;
|
|
16
|
+
private cacheEntry;
|
|
17
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemyxBackendClient = void 0;
|
|
4
|
+
class SchemyxBackendClient {
|
|
5
|
+
config;
|
|
6
|
+
contextCache = null;
|
|
7
|
+
manifestCache = new Map();
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
}
|
|
11
|
+
async getContext() {
|
|
12
|
+
const cached = this.contextCache;
|
|
13
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
14
|
+
return cached.value;
|
|
15
|
+
}
|
|
16
|
+
const value = await this.request('/mcp/context');
|
|
17
|
+
this.contextCache = this.cacheEntry(value);
|
|
18
|
+
return value;
|
|
19
|
+
}
|
|
20
|
+
async listConfigs() {
|
|
21
|
+
const context = await this.getContext();
|
|
22
|
+
const configs = context.projects
|
|
23
|
+
.filter((project) => !this.config.projectId || project.id === this.config.projectId)
|
|
24
|
+
.flatMap((project) => project.configs);
|
|
25
|
+
if (this.config.configId) {
|
|
26
|
+
return configs.filter((config) => config.id === this.config.configId);
|
|
27
|
+
}
|
|
28
|
+
return configs;
|
|
29
|
+
}
|
|
30
|
+
async discoverConfigs() {
|
|
31
|
+
const configs = await this.listConfigs();
|
|
32
|
+
return Promise.all(configs.map(async (config) => ({
|
|
33
|
+
config,
|
|
34
|
+
manifest: await this.getManifest(config.id),
|
|
35
|
+
})));
|
|
36
|
+
}
|
|
37
|
+
async getManifest(configId) {
|
|
38
|
+
const cached = this.manifestCache.get(configId);
|
|
39
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
40
|
+
return cached.value;
|
|
41
|
+
}
|
|
42
|
+
const value = await this.request(`/mcp/configs/${configId}/manifest`);
|
|
43
|
+
this.manifestCache.set(configId, this.cacheEntry(value));
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
async getLatestConfig(configId) {
|
|
47
|
+
return this.request(`/mcp/configs/${configId}/latest`);
|
|
48
|
+
}
|
|
49
|
+
async readResource(configId, resourceId) {
|
|
50
|
+
return this.request(`/mcp/configs/${configId}/resources/${encodeURIComponent(resourceId)}`);
|
|
51
|
+
}
|
|
52
|
+
async executeTool(configId, toolName, args) {
|
|
53
|
+
return this.request(`/mcp/configs/${configId}/tools/${encodeURIComponent(toolName)}`, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
body: JSON.stringify({ arguments: args }),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
async resolveConfigId(configId) {
|
|
59
|
+
if (configId) {
|
|
60
|
+
return configId;
|
|
61
|
+
}
|
|
62
|
+
const configs = await this.listConfigs();
|
|
63
|
+
if (configs.length === 1) {
|
|
64
|
+
return configs[0].id;
|
|
65
|
+
}
|
|
66
|
+
if (configs.length === 0) {
|
|
67
|
+
throw new Error('No Schemyx configs are available for this API key.');
|
|
68
|
+
}
|
|
69
|
+
throw new Error('Multiple configs are available. Pass configId to choose one.');
|
|
70
|
+
}
|
|
71
|
+
async request(path, init) {
|
|
72
|
+
if (!this.config.apiKey) {
|
|
73
|
+
throw new Error('SCHEMYX_API_KEY is required when no local Schemyx theme files are available.');
|
|
74
|
+
}
|
|
75
|
+
const response = await fetch(`${this.config.apiUrl}${path}`, {
|
|
76
|
+
...init,
|
|
77
|
+
headers: {
|
|
78
|
+
Accept: 'application/json',
|
|
79
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
80
|
+
...(init?.body ? { 'Content-Type': 'application/json' } : {}),
|
|
81
|
+
...init?.headers,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
throw new Error(`Schemyx API request failed: ${response.status} ${response.statusText} ${await response.text()}`);
|
|
86
|
+
}
|
|
87
|
+
return (await response.json());
|
|
88
|
+
}
|
|
89
|
+
cacheEntry(value) {
|
|
90
|
+
return {
|
|
91
|
+
expiresAt: Date.now() + this.config.cacheTtlMs,
|
|
92
|
+
value,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
exports.SchemyxBackendClient = SchemyxBackendClient;
|
|
97
|
+
//# sourceMappingURL=backend-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend-client.js","sourceRoot":"","sources":["../../src/client/backend-client.ts"],"names":[],"mappings":";;;AAWA,MAAa,oBAAoB;IAIF;IAHrB,YAAY,GAA4D,IAAI,CAAC;IAC7E,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AC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAC;IACtC,CAAC;IAEO,UAAU,CAAI,KAAQ;QAC5B,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU;YAC9C,KAAK;SACN,CAAC;IACJ,CAAC;CACF;AAhID,oDAgIC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { BackendConfigManifest, BackendResourceContent, BackendToolResult, DiscoveredConfig, LocalMcpConfig, McpConfigResponse, SchemyxMcpSource } from '../shared/types';
|
|
2
|
+
export declare function createLocalThemeSourceIfAvailable(config: LocalMcpConfig): Promise<LocalThemeSource | null>;
|
|
3
|
+
export declare class LocalThemeSource implements SchemyxMcpSource {
|
|
4
|
+
private readonly themeDir;
|
|
5
|
+
private bundleCache;
|
|
6
|
+
private configCache;
|
|
7
|
+
constructor(themeDir: string);
|
|
8
|
+
listConfigs(): Promise<McpConfigResponse[]>;
|
|
9
|
+
discoverConfigs(): Promise<DiscoveredConfig[]>;
|
|
10
|
+
getManifest(configId: string): Promise<BackendConfigManifest>;
|
|
11
|
+
getLatestConfig(configId: string): Promise<McpConfigResponse>;
|
|
12
|
+
readResource(configId: string, resourceId: string): Promise<BackendResourceContent>;
|
|
13
|
+
executeTool(configId: string, toolName: string, args: Record<string, unknown>): Promise<BackendToolResult>;
|
|
14
|
+
resolveConfigId(configId: string | undefined): Promise<string>;
|
|
15
|
+
private getBundle;
|
|
16
|
+
private getLocalConfig;
|
|
17
|
+
private createLocalConfig;
|
|
18
|
+
private assertLocalConfig;
|
|
19
|
+
}
|