@soldy_ai/mcp 0.1.6
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 +42 -0
- package/dist/client.d.ts +103 -0
- package/dist/client.js +165 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +22 -0
- package/dist/errors.js.map +1 -0
- package/dist/files.d.ts +6 -0
- package/dist/files.js +49 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/brands.d.ts +3 -0
- package/dist/resources/brands.js +170 -0
- package/dist/resources/brands.js.map +1 -0
- package/dist/resources/materials.d.ts +3 -0
- package/dist/resources/materials.js +134 -0
- package/dist/resources/materials.js.map +1 -0
- package/dist/resources/messages.d.ts +3 -0
- package/dist/resources/messages.js +135 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/resources/projects.d.ts +3 -0
- package/dist/resources/projects.js +78 -0
- package/dist/resources/projects.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.js +171 -0
- package/dist/server.js.map +1 -0
- package/dist/subscriptions.d.ts +45 -0
- package/dist/subscriptions.js +275 -0
- package/dist/subscriptions.js.map +1 -0
- package/dist/tools/brand.d.ts +3 -0
- package/dist/tools/brand.js +141 -0
- package/dist/tools/brand.js.map +1 -0
- package/dist/tools/material.d.ts +2 -0
- package/dist/tools/material.js +23 -0
- package/dist/tools/material.js.map +1 -0
- package/dist/tools/message.d.ts +3 -0
- package/dist/tools/message.js +241 -0
- package/dist/tools/message.js.map +1 -0
- package/dist/tools/project.d.ts +3 -0
- package/dist/tools/project.js +240 -0
- package/dist/tools/project.js.map +1 -0
- package/dist/tools/subscribe.d.ts +12 -0
- package/dist/tools/subscribe.js +74 -0
- package/dist/tools/subscribe.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @soldy_ai/mcp
|
|
2
|
+
|
|
3
|
+
A Model Context Protocol (MCP) server for [Soldy AI](https://soldy.ai) — generate video ads, extract brand identities, and manage creative projects from any MCP client.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### Claude Desktop / Cursor
|
|
8
|
+
|
|
9
|
+
Add to your MCP configuration (`claude_desktop_config.json`):
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"mcpServers": {
|
|
14
|
+
"soldy": {
|
|
15
|
+
"command": "npx",
|
|
16
|
+
"args": ["-y", "@soldy_ai/mcp"],
|
|
17
|
+
"env": {
|
|
18
|
+
"SOLDY_API_KEY": "<your-api-key>"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Claude Code
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
claude mcp add soldy -e SOLDY_API_KEY=<your-api-key> -- npx -y @soldy_ai/mcp
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Get your API key at [app.soldy.ai/app/settings](https://app.soldy.ai/app/settings).
|
|
32
|
+
|
|
33
|
+
## What You Can Do
|
|
34
|
+
|
|
35
|
+
- Create and manage video ad projects across aspect ratios (9:16, 16:9, 1:1, etc.)
|
|
36
|
+
- Extract brand identity from a product URL or website
|
|
37
|
+
- Send generation requests with text prompts and reference media (local files or URLs)
|
|
38
|
+
- Monitor generation progress, pause/resume, and retrieve final assets
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
Proprietary
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export interface ApiResponse<T = unknown> {
|
|
2
|
+
code: number;
|
|
3
|
+
msg: string;
|
|
4
|
+
msg_code?: string;
|
|
5
|
+
data?: T;
|
|
6
|
+
page?: {
|
|
7
|
+
total_count: number;
|
|
8
|
+
page_index: number;
|
|
9
|
+
page_count: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface Project {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
status: string;
|
|
16
|
+
ratio: string;
|
|
17
|
+
description: string;
|
|
18
|
+
created_at: string;
|
|
19
|
+
brand_id: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Message {
|
|
22
|
+
id: string;
|
|
23
|
+
role: string;
|
|
24
|
+
content: string;
|
|
25
|
+
event: string;
|
|
26
|
+
run_id: string;
|
|
27
|
+
materials: Material[];
|
|
28
|
+
tool: {
|
|
29
|
+
name: string;
|
|
30
|
+
input?: Record<string, unknown>;
|
|
31
|
+
output?: Record<string, unknown>;
|
|
32
|
+
} | null;
|
|
33
|
+
metadata: Record<string, unknown> | null;
|
|
34
|
+
created_at: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Material {
|
|
37
|
+
url: string;
|
|
38
|
+
type: string;
|
|
39
|
+
thumbnail?: string;
|
|
40
|
+
display_title?: string;
|
|
41
|
+
asset_category?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface MaterialGroup {
|
|
44
|
+
run_id: string;
|
|
45
|
+
source: string;
|
|
46
|
+
materials: Material[];
|
|
47
|
+
created_at: string;
|
|
48
|
+
}
|
|
49
|
+
export interface Brand {
|
|
50
|
+
id: string;
|
|
51
|
+
name: string;
|
|
52
|
+
description: string;
|
|
53
|
+
stage: string;
|
|
54
|
+
}
|
|
55
|
+
export interface BrandTask {
|
|
56
|
+
id: string;
|
|
57
|
+
status: string;
|
|
58
|
+
progress: number;
|
|
59
|
+
brand_id: string;
|
|
60
|
+
reason: string;
|
|
61
|
+
}
|
|
62
|
+
export declare class SoldyAPIClient {
|
|
63
|
+
private baseUrl;
|
|
64
|
+
private apiKey;
|
|
65
|
+
private cachedWorkspaceId;
|
|
66
|
+
/** Short-lived cache for listProjects (avoids redundant calls during resources/list). */
|
|
67
|
+
private projectsCache;
|
|
68
|
+
private static readonly PROJECTS_CACHE_TTL;
|
|
69
|
+
/** Short-lived cache for listBrands. */
|
|
70
|
+
private brandsCache;
|
|
71
|
+
private static readonly BRANDS_CACHE_TTL;
|
|
72
|
+
constructor(baseUrl: string, apiKey: string);
|
|
73
|
+
/**
|
|
74
|
+
* Get the default workspace ID (first workspace in the org).
|
|
75
|
+
* Cached after first call.
|
|
76
|
+
*/
|
|
77
|
+
getDefaultWorkspaceId(): Promise<string>;
|
|
78
|
+
private headers;
|
|
79
|
+
private request;
|
|
80
|
+
get<T>(path: string, params?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
81
|
+
post<T>(path: string, body?: unknown): Promise<ApiResponse<T>>;
|
|
82
|
+
delete<T>(path: string, params?: Record<string, string>): Promise<ApiResponse<T>>;
|
|
83
|
+
/** List all projects in the default workspace (cached for 5s). */
|
|
84
|
+
listProjects(page?: number, pageSize?: number): Promise<Project[]>;
|
|
85
|
+
/** Get a single project by ID. */
|
|
86
|
+
getProject(projectId: string): Promise<Project | undefined>;
|
|
87
|
+
/** List messages for a project. */
|
|
88
|
+
listMessages(projectId: string, page?: number, pageSize?: number): Promise<{
|
|
89
|
+
messages: Message[];
|
|
90
|
+
total: number;
|
|
91
|
+
}>;
|
|
92
|
+
/** Get all materials for a project. */
|
|
93
|
+
getMaterials(projectId: string): Promise<Material[]>;
|
|
94
|
+
/** Get materials grouped by run_id. */
|
|
95
|
+
getMaterialsGrouped(projectId: string): Promise<MaterialGroup[]>;
|
|
96
|
+
/** List all brands in the default workspace (cached for 5s). */
|
|
97
|
+
listBrands(): Promise<Brand[]>;
|
|
98
|
+
/** Get brand extraction task result. */
|
|
99
|
+
getBrandTaskResult(taskId: string): Promise<BrandTask | undefined>;
|
|
100
|
+
/** Get the WebSocket URL for this API. */
|
|
101
|
+
getWebSocketUrl(apiKey: string): string;
|
|
102
|
+
uploadFile(path: string, filePath: string, fields?: Record<string, string>): Promise<ApiResponse>;
|
|
103
|
+
}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
export class SoldyAPIClient {
|
|
4
|
+
baseUrl;
|
|
5
|
+
apiKey;
|
|
6
|
+
cachedWorkspaceId = null;
|
|
7
|
+
/** Short-lived cache for listProjects (avoids redundant calls during resources/list). */
|
|
8
|
+
projectsCache = null;
|
|
9
|
+
static PROJECTS_CACHE_TTL = 5_000; // 5 seconds
|
|
10
|
+
/** Short-lived cache for listBrands. */
|
|
11
|
+
brandsCache = null;
|
|
12
|
+
static BRANDS_CACHE_TTL = 5_000;
|
|
13
|
+
constructor(baseUrl, apiKey) {
|
|
14
|
+
this.baseUrl = baseUrl;
|
|
15
|
+
this.apiKey = apiKey;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get the default workspace ID (first workspace in the org).
|
|
19
|
+
* Cached after first call.
|
|
20
|
+
*/
|
|
21
|
+
async getDefaultWorkspaceId() {
|
|
22
|
+
if (this.cachedWorkspaceId)
|
|
23
|
+
return this.cachedWorkspaceId;
|
|
24
|
+
const resp = await this.get("/public/workspace/list");
|
|
25
|
+
const workspaces = resp.data ?? [];
|
|
26
|
+
if (workspaces.length === 0) {
|
|
27
|
+
throw new Error("No workspaces found. Create one at https://soldy.ai");
|
|
28
|
+
}
|
|
29
|
+
this.cachedWorkspaceId = workspaces[0].id;
|
|
30
|
+
return this.cachedWorkspaceId;
|
|
31
|
+
}
|
|
32
|
+
headers() {
|
|
33
|
+
return {
|
|
34
|
+
"X-API-Key": this.apiKey,
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async request(method, path, opts) {
|
|
39
|
+
let url = `${this.baseUrl}/api/v1${path}`;
|
|
40
|
+
if (opts?.params) {
|
|
41
|
+
const qs = new URLSearchParams(opts.params).toString();
|
|
42
|
+
url += `?${qs}`;
|
|
43
|
+
}
|
|
44
|
+
const res = await fetch(url, {
|
|
45
|
+
method,
|
|
46
|
+
headers: this.headers(),
|
|
47
|
+
body: opts?.body ? JSON.stringify(opts.body) : undefined,
|
|
48
|
+
});
|
|
49
|
+
if (!res.ok) {
|
|
50
|
+
throw new Error(`API ${method} ${path}: HTTP ${res.status}`);
|
|
51
|
+
}
|
|
52
|
+
return (await res.json());
|
|
53
|
+
}
|
|
54
|
+
async get(path, params) {
|
|
55
|
+
return this.request("GET", path, { params });
|
|
56
|
+
}
|
|
57
|
+
async post(path, body) {
|
|
58
|
+
return this.request("POST", path, { body });
|
|
59
|
+
}
|
|
60
|
+
async delete(path, params) {
|
|
61
|
+
return this.request("DELETE", path, { params });
|
|
62
|
+
}
|
|
63
|
+
/** List all projects in the default workspace (cached for 5s). */
|
|
64
|
+
async listProjects(page = 1, pageSize = 50) {
|
|
65
|
+
if (page === 1 &&
|
|
66
|
+
this.projectsCache &&
|
|
67
|
+
Date.now() < this.projectsCache.expires) {
|
|
68
|
+
return this.projectsCache.data;
|
|
69
|
+
}
|
|
70
|
+
const wsId = await this.getDefaultWorkspaceId();
|
|
71
|
+
const resp = await this.get("/public/project/list", {
|
|
72
|
+
workspace_id: wsId,
|
|
73
|
+
page: String(page),
|
|
74
|
+
page_size: String(pageSize),
|
|
75
|
+
});
|
|
76
|
+
const data = resp.data ?? [];
|
|
77
|
+
if (page === 1) {
|
|
78
|
+
this.projectsCache = {
|
|
79
|
+
data,
|
|
80
|
+
expires: Date.now() + SoldyAPIClient.PROJECTS_CACHE_TTL,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return data;
|
|
84
|
+
}
|
|
85
|
+
/** Get a single project by ID. */
|
|
86
|
+
async getProject(projectId) {
|
|
87
|
+
const resp = await this.get("/public/project", { id: projectId });
|
|
88
|
+
return resp.data ?? undefined;
|
|
89
|
+
}
|
|
90
|
+
/** List messages for a project. */
|
|
91
|
+
async listMessages(projectId, page = 1, pageSize = 100) {
|
|
92
|
+
const resp = await this.get("/public/project/message/list", {
|
|
93
|
+
project_id: projectId,
|
|
94
|
+
page: String(page),
|
|
95
|
+
page_size: String(pageSize),
|
|
96
|
+
sort: "created_at desc",
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
messages: resp.data ?? [],
|
|
100
|
+
total: resp.page?.total_count ?? resp.data?.length ?? 0,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/** Get all materials for a project. */
|
|
104
|
+
async getMaterials(projectId) {
|
|
105
|
+
const resp = await this.get("/public/project/materials", {
|
|
106
|
+
project_id: projectId,
|
|
107
|
+
});
|
|
108
|
+
return resp.data ?? [];
|
|
109
|
+
}
|
|
110
|
+
/** Get materials grouped by run_id. */
|
|
111
|
+
async getMaterialsGrouped(projectId) {
|
|
112
|
+
const resp = await this.get("/public/project/materials-group", { project_id: projectId });
|
|
113
|
+
return resp.data ?? [];
|
|
114
|
+
}
|
|
115
|
+
/** List all brands in the default workspace (cached for 5s). */
|
|
116
|
+
async listBrands() {
|
|
117
|
+
if (this.brandsCache && Date.now() < this.brandsCache.expires) {
|
|
118
|
+
return this.brandsCache.data;
|
|
119
|
+
}
|
|
120
|
+
const wsId = await this.getDefaultWorkspaceId();
|
|
121
|
+
const resp = await this.get("/public/brand/list", {
|
|
122
|
+
workspace_id: wsId,
|
|
123
|
+
});
|
|
124
|
+
const data = resp.data ?? [];
|
|
125
|
+
this.brandsCache = {
|
|
126
|
+
data,
|
|
127
|
+
expires: Date.now() + SoldyAPIClient.BRANDS_CACHE_TTL,
|
|
128
|
+
};
|
|
129
|
+
return data;
|
|
130
|
+
}
|
|
131
|
+
/** Get brand extraction task result. */
|
|
132
|
+
async getBrandTaskResult(taskId) {
|
|
133
|
+
const wsId = await this.getDefaultWorkspaceId();
|
|
134
|
+
const resp = await this.post("/public/brand/task/result", {
|
|
135
|
+
task_ids: [taskId],
|
|
136
|
+
workspace_id: wsId,
|
|
137
|
+
});
|
|
138
|
+
return resp.data?.[0] ?? undefined;
|
|
139
|
+
}
|
|
140
|
+
/** Get the WebSocket URL for this API. */
|
|
141
|
+
getWebSocketUrl(apiKey) {
|
|
142
|
+
const wsUrl = this.baseUrl.replace(/^http/, "ws");
|
|
143
|
+
return `${wsUrl}/ws?api_key=${encodeURIComponent(apiKey)}`;
|
|
144
|
+
}
|
|
145
|
+
async uploadFile(path, filePath, fields) {
|
|
146
|
+
const fileData = await readFile(filePath);
|
|
147
|
+
const form = new FormData();
|
|
148
|
+
form.append("file", new Blob([fileData]), basename(filePath));
|
|
149
|
+
if (fields) {
|
|
150
|
+
for (const [k, v] of Object.entries(fields)) {
|
|
151
|
+
form.append(k, v);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
const res = await fetch(`${this.baseUrl}/api/v1${path}`, {
|
|
155
|
+
method: "POST",
|
|
156
|
+
headers: { "X-API-Key": this.apiKey },
|
|
157
|
+
body: form,
|
|
158
|
+
});
|
|
159
|
+
if (!res.ok) {
|
|
160
|
+
throw new Error(`Upload ${path}: HTTP ${res.status}`);
|
|
161
|
+
}
|
|
162
|
+
return (await res.json());
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAkErC,MAAM,OAAO,cAAc;IAYf;IACA;IAZF,iBAAiB,GAAkB,IAAI,CAAC;IAEhD,yFAAyF;IACjF,aAAa,GAAgD,IAAI,CAAC;IAClE,MAAM,CAAU,kBAAkB,GAAG,KAAK,CAAC,CAAC,YAAY;IAEhE,wCAAwC;IAChC,WAAW,GAA8C,IAAI,CAAC;IAC9D,MAAM,CAAU,gBAAgB,GAAG,KAAK,CAAC;IAEjD,YACU,OAAe,EACf,MAAc;QADd,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,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ClD,OAAO,GAAG,KAAK,eAAe,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;IAC7D,CAAC;IAED,KAAK,CAAC,UAAU,CACd,IAAY,EACZ,QAAgB,EAChB,MAA+B;QAE/B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAI,QAAQ,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,IAAI,MAAM,EAAE,CAAC;YACX,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5C,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QAED,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,UAAU,IAAI,EAAE,EAAE;YACvD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE;YACrC,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,UAAU,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAC;IAC3C,CAAC"}
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const friendlyMessages = {
|
|
2
|
+
INSUFFICIENT_CREDITS: "Credits balance insufficient. Top up at https://soldy.ai/app/settings/billing",
|
|
3
|
+
PROJECT_NOT_FOUND: "Project not found. Check the project_id.",
|
|
4
|
+
WORKSPACE_NOT_FOUND: "Workspace not found.",
|
|
5
|
+
BRAND_NOT_FOUND: "Brand not found. Check the brand_id.",
|
|
6
|
+
PROJECT_LIMIT_EXCEEDED: "Project limit reached. Upgrade your plan or delete old projects.",
|
|
7
|
+
RATE_LIMIT_EXCEEDED: "Too many requests. Please try again shortly.",
|
|
8
|
+
BRAND_TASK_NOT_FOUND: "Brand task not found. Check the task_id.",
|
|
9
|
+
API_KEY_REQUIRED: "API Key required. Set SOLDY_API_KEY environment variable.",
|
|
10
|
+
INVALID_API_KEY: "API Key invalid or revoked.",
|
|
11
|
+
TOKEN_REQUIRED: "Authentication required. Check your API key.",
|
|
12
|
+
};
|
|
13
|
+
export function mapError(code, fallback) {
|
|
14
|
+
return friendlyMessages[code] ?? fallback;
|
|
15
|
+
}
|
|
16
|
+
export function formatApiError(resp) {
|
|
17
|
+
if (resp.msg_code && friendlyMessages[resp.msg_code]) {
|
|
18
|
+
return friendlyMessages[resp.msg_code];
|
|
19
|
+
}
|
|
20
|
+
return resp.msg ?? "Unknown error";
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,gBAAgB,GAA2B;IAC/C,oBAAoB,EAClB,+EAA+E;IACjF,iBAAiB,EAAE,0CAA0C;IAC7D,mBAAmB,EAAE,sBAAsB;IAC3C,eAAe,EAAE,sCAAsC;IACvD,sBAAsB,EACpB,kEAAkE;IACpE,mBAAmB,EAAE,8CAA8C;IACnE,oBAAoB,EAAE,0CAA0C;IAChE,gBAAgB,EAAE,2DAA2D;IAC7E,eAAe,EAAE,6BAA6B;IAC9C,cAAc,EAAE,8CAA8C;CAC/D,CAAC;AAEF,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,gBAAgB,CAAC,IAAI,CAAC,IAAI,QAAQ,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAG9B;IACC,IAAI,IAAI,CAAC,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrD,OAAO,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,IAAI,eAAe,CAAC;AACrC,CAAC"}
|
package/dist/files.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SoldyAPIClient } from "./client.js";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve material URLs: local files get uploaded, HTTP URLs pass through.
|
|
4
|
+
* Returns an array of GCS URLs ready for the API.
|
|
5
|
+
*/
|
|
6
|
+
export declare function resolveUrls(client: SoldyAPIClient, urls: string[]): Promise<string[]>;
|
package/dist/files.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* Detect if a string is a local file path (not a URL).
|
|
5
|
+
*/
|
|
6
|
+
function isLocalPath(s) {
|
|
7
|
+
if (s.startsWith("http://") || s.startsWith("https://"))
|
|
8
|
+
return false;
|
|
9
|
+
if (s.startsWith("/") ||
|
|
10
|
+
s.startsWith("./") ||
|
|
11
|
+
s.startsWith("../") ||
|
|
12
|
+
s.startsWith("~"))
|
|
13
|
+
return true;
|
|
14
|
+
// Windows paths
|
|
15
|
+
if (/^[A-Z]:\\/i.test(s))
|
|
16
|
+
return true;
|
|
17
|
+
// Relative path that exists
|
|
18
|
+
return existsSync(s);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve material URLs: local files get uploaded, HTTP URLs pass through.
|
|
22
|
+
* Returns an array of GCS URLs ready for the API.
|
|
23
|
+
*/
|
|
24
|
+
export async function resolveUrls(client, urls) {
|
|
25
|
+
const results = [];
|
|
26
|
+
for (const raw of urls) {
|
|
27
|
+
if (isLocalPath(raw)) {
|
|
28
|
+
const absPath = resolve(raw);
|
|
29
|
+
if (!existsSync(absPath)) {
|
|
30
|
+
throw new Error(`Local file not found: ${raw}`);
|
|
31
|
+
}
|
|
32
|
+
const resp = await client.uploadFile("/public/material", absPath);
|
|
33
|
+
if (resp.code !== 0 || !resp.data) {
|
|
34
|
+
throw new Error(`Upload failed for ${raw}: ${resp.msg}`);
|
|
35
|
+
}
|
|
36
|
+
const data = resp.data;
|
|
37
|
+
if (!data.url) {
|
|
38
|
+
throw new Error(`Upload returned no URL for ${raw}`);
|
|
39
|
+
}
|
|
40
|
+
results.push(data.url);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// HTTP URL — pass through directly
|
|
44
|
+
results.push(raw);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return results;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;;GAEG;AACH,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,IACE,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;QACjB,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC;QAClB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC;QACnB,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC;QAEjB,OAAO,IAAI,CAAC;IACd,gBAAgB;IAChB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC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elcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
import { createServer } from "./server.js";
|
|
4
|
+
const apiKey = process.env.SOLDY_API_KEY;
|
|
5
|
+
if (!apiKey) {
|
|
6
|
+
console.error("Error: SOLDY_API_KEY environment variable is required.");
|
|
7
|
+
console.error("Get your API key at https://soldy.ai/app/settings");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
const apiUrl = process.env.SOLDY_API_URL ?? "https://api.soldy.ai";
|
|
11
|
+
const { server, bridge } = createServer(apiUrl, apiKey);
|
|
12
|
+
const transport = new StdioServerTransport();
|
|
13
|
+
await server.connect(transport);
|
|
14
|
+
// Attach bridge to the low-level Server for sending notifications
|
|
15
|
+
bridge.setServer(server.server);
|
|
16
|
+
// Log to stderr (stdout is reserved for JSON-RPC)
|
|
17
|
+
console.error(`Soldy MCP server running (API: ${apiUrl})`);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AACzC,IAAI,CAAC,MAAM,EAAE,CAAC;IACZ,OAAO,CAAC,KAAK,CAAC,wDAAwD,CAAC,CAAC;IACxE,OAAO,CAAC,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACnE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,sBAAsB,CAAC;AAEnE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AACxD,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;AAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAEhC,kEAAkE;AAClE,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAEhC,kDAAkD;AAClD,OAAO,CAAC,KAAK,CAAC,kCAAkC,MAAM,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
export function registerBrandResources(server, client) {
|
|
3
|
+
server.resource("brands", new ResourceTemplate("soldy://brands", {
|
|
4
|
+
list: async () => ({
|
|
5
|
+
resources: [
|
|
6
|
+
{
|
|
7
|
+
uri: "soldy://brands",
|
|
8
|
+
name: "All Brands",
|
|
9
|
+
description: "List of all brands in the workspace",
|
|
10
|
+
mimeType: "application/json",
|
|
11
|
+
},
|
|
12
|
+
],
|
|
13
|
+
}),
|
|
14
|
+
}), {
|
|
15
|
+
title: "Brands",
|
|
16
|
+
description: "All brands in the workspace",
|
|
17
|
+
mimeType: "application/json",
|
|
18
|
+
}, async (uri) => {
|
|
19
|
+
try {
|
|
20
|
+
const brands = await client.listBrands();
|
|
21
|
+
return {
|
|
22
|
+
contents: [
|
|
23
|
+
{
|
|
24
|
+
uri: uri.href,
|
|
25
|
+
mimeType: "application/json",
|
|
26
|
+
text: JSON.stringify({ count: brands.length, brands }, null, 2),
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
return {
|
|
33
|
+
contents: [
|
|
34
|
+
{
|
|
35
|
+
uri: uri.href,
|
|
36
|
+
mimeType: "application/json",
|
|
37
|
+
text: JSON.stringify({
|
|
38
|
+
error: err instanceof Error ? err.message : "Failed to fetch",
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
server.resource("brand-detail", new ResourceTemplate("soldy://brand/{brand_id}", {
|
|
46
|
+
list: async () => {
|
|
47
|
+
try {
|
|
48
|
+
const brands = await client.listBrands();
|
|
49
|
+
return {
|
|
50
|
+
resources: brands.map((b) => ({
|
|
51
|
+
uri: `soldy://brand/${b.id}`,
|
|
52
|
+
name: b.name,
|
|
53
|
+
description: `Brand: ${b.name} (stage: ${b.stage})`,
|
|
54
|
+
mimeType: "application/json",
|
|
55
|
+
})),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
catch (err) {
|
|
59
|
+
console.error("[resource:brand-detail] list failed:", err);
|
|
60
|
+
return { resources: [] };
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
complete: {
|
|
64
|
+
brand_id: async (value) => {
|
|
65
|
+
try {
|
|
66
|
+
const brands = await client.listBrands();
|
|
67
|
+
return brands
|
|
68
|
+
.filter((b) => b.id.startsWith(value) ||
|
|
69
|
+
b.name.toLowerCase().includes(value.toLowerCase()))
|
|
70
|
+
.map((b) => b.id);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
}), {
|
|
78
|
+
title: "Brand Detail",
|
|
79
|
+
description: "Details of a specific brand",
|
|
80
|
+
mimeType: "application/json",
|
|
81
|
+
}, async (uri, { brand_id }) => {
|
|
82
|
+
const id = Array.isArray(brand_id) ? brand_id[0] : brand_id;
|
|
83
|
+
try {
|
|
84
|
+
const brands = await client.listBrands();
|
|
85
|
+
const brand = brands.find((b) => b.id === id);
|
|
86
|
+
if (!brand) {
|
|
87
|
+
return {
|
|
88
|
+
contents: [
|
|
89
|
+
{
|
|
90
|
+
uri: uri.href,
|
|
91
|
+
mimeType: "application/json",
|
|
92
|
+
text: JSON.stringify({ error: "Brand not found" }),
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
contents: [
|
|
99
|
+
{
|
|
100
|
+
uri: uri.href,
|
|
101
|
+
mimeType: "application/json",
|
|
102
|
+
text: JSON.stringify(brand, null, 2),
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
catch (err) {
|
|
108
|
+
return {
|
|
109
|
+
contents: [
|
|
110
|
+
{
|
|
111
|
+
uri: uri.href,
|
|
112
|
+
mimeType: "application/json",
|
|
113
|
+
text: JSON.stringify({
|
|
114
|
+
error: err instanceof Error ? err.message : "Failed to fetch",
|
|
115
|
+
}),
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
server.resource("brand-task", new ResourceTemplate("soldy://brand/task/{task_id}", {
|
|
122
|
+
list: undefined,
|
|
123
|
+
complete: {
|
|
124
|
+
task_id: async () => [],
|
|
125
|
+
},
|
|
126
|
+
}), {
|
|
127
|
+
title: "Brand Extraction Task",
|
|
128
|
+
description: "Status and result of a brand extraction task. Subscribe for updates.",
|
|
129
|
+
mimeType: "application/json",
|
|
130
|
+
}, async (uri, { task_id }) => {
|
|
131
|
+
const id = Array.isArray(task_id) ? task_id[0] : task_id;
|
|
132
|
+
try {
|
|
133
|
+
const task = await client.getBrandTaskResult(id);
|
|
134
|
+
if (!task) {
|
|
135
|
+
return {
|
|
136
|
+
contents: [
|
|
137
|
+
{
|
|
138
|
+
uri: uri.href,
|
|
139
|
+
mimeType: "application/json",
|
|
140
|
+
text: JSON.stringify({ error: "Task not found" }),
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
contents: [
|
|
147
|
+
{
|
|
148
|
+
uri: uri.href,
|
|
149
|
+
mimeType: "application/json",
|
|
150
|
+
text: JSON.stringify(task, null, 2),
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
catch (err) {
|
|
156
|
+
return {
|
|
157
|
+
contents: [
|
|
158
|
+
{
|
|
159
|
+
uri: uri.href,
|
|
160
|
+
mimeType: "application/json",
|
|
161
|
+
text: JSON.stringify({
|
|
162
|
+
error: err instanceof Error ? err.message : "Failed to fetch",
|
|
163
|
+
}),
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=brands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brands.js","sourceRoot":"","sources":["../../src/resources/brands.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAG3E,MAAM,UAAU,sBAAsB,CACpC,MAAiB,EACjB,MAAsB;IAEtB,MAAM,CAAC,QAAQ,CACb,QAAQ,EACR,IAAI,gBAAgB,CAAC,gBAAgB,EAAE;QACrC,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC;YACjB,SAAS,EAAE;gBACT;oBACE,GAAG,EAAE,gBAAgB;oBACrB,IAAI,EAAE,YAAY;oBAClB,WAAW,EAAE,qCAAqC;oBAClD,QAAQ,EAAE,kBAAkB;iBAC7B;aACF;SACF,CAAC;KACH,CAAC,EACF;QACE,KAAK,EAAE,QAAQ;QACf,WAAW,EAAE,6BAA6B;QAC1C,QAAQ,EAAE,kBAAkB;KAC7B,EACD,KAAK,EAAE,GAAG,EAAE,EAAE;QACZ,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;YACzC,OAAO;gBACL,QAAQ,EAAE;oBACR;wBACE,GAAG,EAAE,GAAG,CAAC,IAAI;wBACb,QAAQ,EAAE,kBAAkB;wBAC5B,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;qB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