@sgcarstrends/mcp 4.51.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/LICENSE +21 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +26 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +137 -0
- package/package.json +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 SG Cars Trends
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/client.d.ts
ADDED
package/dist/client.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { withRelatedProject } from "@vercel/related-projects";
|
|
2
|
+
const baseUrl = withRelatedProject({
|
|
3
|
+
projectName: "web",
|
|
4
|
+
defaultHost: "https://sgcarstrends.com",
|
|
5
|
+
});
|
|
6
|
+
const apiToken = process.env.SG_CARS_TRENDS_API_TOKEN;
|
|
7
|
+
export async function request(path, options = {}) {
|
|
8
|
+
if (!apiToken) {
|
|
9
|
+
throw new Error("SG_CARS_TRENDS_API_TOKEN environment variable is not set");
|
|
10
|
+
}
|
|
11
|
+
const url = `${baseUrl}${path}`;
|
|
12
|
+
const response = await fetch(url, {
|
|
13
|
+
...options,
|
|
14
|
+
headers: {
|
|
15
|
+
"Content-Type": "application/json",
|
|
16
|
+
Authorization: `Bearer ${apiToken}`,
|
|
17
|
+
...options.headers,
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const data = await response.json();
|
|
21
|
+
return {
|
|
22
|
+
ok: response.ok,
|
|
23
|
+
status: response.status,
|
|
24
|
+
data: data,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import * as z from "zod";
|
|
5
|
+
import pkg from "../package.json" with { type: "json" };
|
|
6
|
+
import { request } from "./client.js";
|
|
7
|
+
function errorResult(response) {
|
|
8
|
+
return {
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: "text",
|
|
12
|
+
text: `Error ${response.status}: ${JSON.stringify(response.data)}`,
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
isError: true,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function jsonResult(data) {
|
|
19
|
+
return {
|
|
20
|
+
content: [
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
text: JSON.stringify(data, null, 2),
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
const postBodySchema = {
|
|
29
|
+
title: z.string().min(1).describe("Post title"),
|
|
30
|
+
content: z.string().min(1).describe("Post content in MDX format"),
|
|
31
|
+
excerpt: z.string().optional().describe("Short excerpt/summary"),
|
|
32
|
+
heroImage: z.string().optional().describe("Hero image URL"),
|
|
33
|
+
tags: z.array(z.string()).optional().describe("Post tags"),
|
|
34
|
+
highlights: z
|
|
35
|
+
.array(z.object({
|
|
36
|
+
value: z.string(),
|
|
37
|
+
label: z.string(),
|
|
38
|
+
detail: z.string(),
|
|
39
|
+
}))
|
|
40
|
+
.optional()
|
|
41
|
+
.describe("Key highlights to display"),
|
|
42
|
+
month: z
|
|
43
|
+
.string()
|
|
44
|
+
.optional()
|
|
45
|
+
.describe("Data month (e.g. 2024-01) for deduplication"),
|
|
46
|
+
dataType: z
|
|
47
|
+
.string()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Data type (e.g. cars, coe) for deduplication"),
|
|
50
|
+
status: z
|
|
51
|
+
.enum(["draft", "published"])
|
|
52
|
+
.default("draft")
|
|
53
|
+
.describe("Post status"),
|
|
54
|
+
};
|
|
55
|
+
const server = new McpServer({
|
|
56
|
+
name: pkg.name,
|
|
57
|
+
version: pkg.version,
|
|
58
|
+
});
|
|
59
|
+
server.tool("list_posts", "List blog posts with optional status filter and limit", {
|
|
60
|
+
status: z
|
|
61
|
+
.enum(["draft", "published"])
|
|
62
|
+
.optional()
|
|
63
|
+
.describe("Filter by post status"),
|
|
64
|
+
limit: z
|
|
65
|
+
.number()
|
|
66
|
+
.int()
|
|
67
|
+
.positive()
|
|
68
|
+
.max(100)
|
|
69
|
+
.optional()
|
|
70
|
+
.describe("Maximum number of posts to return (default 50)"),
|
|
71
|
+
}, async ({ status, limit }) => {
|
|
72
|
+
const params = new URLSearchParams();
|
|
73
|
+
if (status)
|
|
74
|
+
params.set("status", status);
|
|
75
|
+
if (limit)
|
|
76
|
+
params.set("limit", String(limit));
|
|
77
|
+
const query = params.toString();
|
|
78
|
+
const path = `/api/v1/posts${query ? `?${query}` : ""}`;
|
|
79
|
+
const response = await request(path);
|
|
80
|
+
if (!response.ok)
|
|
81
|
+
return errorResult(response);
|
|
82
|
+
return jsonResult(response.data);
|
|
83
|
+
});
|
|
84
|
+
server.tool("get_post", "Get a single blog post by its UUID", {
|
|
85
|
+
id: z.string().uuid().describe("The UUID of the post"),
|
|
86
|
+
}, async ({ id }) => {
|
|
87
|
+
const response = await request(`/api/v1/posts/${id}`);
|
|
88
|
+
if (!response.ok)
|
|
89
|
+
return errorResult(response);
|
|
90
|
+
return jsonResult(response.data);
|
|
91
|
+
});
|
|
92
|
+
server.tool("create_post", "Create a new blog post", postBodySchema, async (input) => {
|
|
93
|
+
const response = await request("/api/v1/posts", {
|
|
94
|
+
method: "POST",
|
|
95
|
+
body: JSON.stringify(input),
|
|
96
|
+
});
|
|
97
|
+
if (!response.ok)
|
|
98
|
+
return errorResult(response);
|
|
99
|
+
return jsonResult(response.data);
|
|
100
|
+
});
|
|
101
|
+
server.tool("update_post", "Update an existing blog post", {
|
|
102
|
+
id: z.string().uuid().describe("The UUID of the post to update"),
|
|
103
|
+
...postBodySchema,
|
|
104
|
+
}, async ({ id, ...body }) => {
|
|
105
|
+
const response = await request(`/api/v1/posts/${id}`, {
|
|
106
|
+
method: "PUT",
|
|
107
|
+
body: JSON.stringify(body),
|
|
108
|
+
});
|
|
109
|
+
if (!response.ok)
|
|
110
|
+
return errorResult(response);
|
|
111
|
+
return jsonResult(response.data);
|
|
112
|
+
});
|
|
113
|
+
server.tool("delete_post", "Delete a blog post permanently", {
|
|
114
|
+
id: z.string().uuid().describe("The UUID of the post to delete"),
|
|
115
|
+
}, async ({ id }) => {
|
|
116
|
+
const response = await request(`/api/v1/posts/${id}`, {
|
|
117
|
+
method: "DELETE",
|
|
118
|
+
});
|
|
119
|
+
if (!response.ok)
|
|
120
|
+
return errorResult(response);
|
|
121
|
+
return {
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: "text",
|
|
125
|
+
text: `Post ${id} deleted successfully.`,
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
129
|
+
});
|
|
130
|
+
async function main() {
|
|
131
|
+
const transport = new StdioServerTransport();
|
|
132
|
+
await server.connect(transport);
|
|
133
|
+
}
|
|
134
|
+
main().catch((error) => {
|
|
135
|
+
console.error("Fatal error:", error);
|
|
136
|
+
process.exit(1);
|
|
137
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sgcarstrends/mcp",
|
|
3
|
+
"version": "4.51.1",
|
|
4
|
+
"description": "MCP server for SG Cars Trends blog post management",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": "dist/index.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/sgcarstrends/sgcarstrends.git",
|
|
13
|
+
"directory": "apps/mcp"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
18
|
+
"@vercel/related-projects": "^1.0.0",
|
|
19
|
+
"zod": "^4.1.13"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"typescript": "^5.8.3"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsc",
|
|
26
|
+
"dev": "tsc --watch"
|
|
27
|
+
}
|
|
28
|
+
}
|