create-mcp-use-app 0.14.17 → 2.0.0-beta.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/README.md +2 -8
- package/dist/ansi.d.ts +9 -0
- package/dist/ansi.d.ts.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1768 -629
- package/dist/prompts.d.ts +16 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/templates/blank/index.ts +4 -92
- package/dist/templates/blank/package.json +3 -12
- package/dist/templates/mcp-apps/index.ts +28 -122
- package/dist/templates/mcp-apps/package.json +7 -14
- package/dist/templates/mcp-apps/resources/product-search-result/view.tsx +26 -0
- package/dist/templates/mcp-apps/src/register.d.ts +7 -0
- package/dist/templates/mcp-apps/tsconfig.json +8 -14
- package/dist/templates/starter/index.ts +43 -80
- package/dist/templates/starter/package.json +5 -18
- package/package.json +4 -12
- package/dist/templates/mcp-apps/pnpm-workspace.yaml +0 -2
- package/dist/templates/mcp-apps/resources/product-search-result/components/Accordion.tsx +0 -35
- package/dist/templates/mcp-apps/resources/product-search-result/components/AccordionItem.tsx +0 -32
- package/dist/templates/mcp-apps/resources/product-search-result/components/Carousel.tsx +0 -51
- package/dist/templates/mcp-apps/resources/product-search-result/components/CarouselItem.tsx +0 -54
- package/dist/templates/mcp-apps/resources/product-search-result/components/CarouselSkeleton.tsx +0 -20
- package/dist/templates/mcp-apps/resources/product-search-result/hooks/useCarouselAnimation.ts +0 -78
- package/dist/templates/mcp-apps/resources/product-search-result/types.ts +0 -20
- package/dist/templates/mcp-apps/resources/product-search-result/widget.tsx +0 -288
- package/dist/templates/mcp-apps/resources/styles.css +0 -117
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as p from "@clack/prompts";
|
|
2
|
+
export declare function isInteractive(): boolean;
|
|
3
|
+
type PromptTextOptions = {
|
|
4
|
+
defaultValue?: string;
|
|
5
|
+
validate?: (value: string) => string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export declare function promptText(message: string, options?: PromptTextOptions): Promise<string>;
|
|
8
|
+
export declare function promptConfirm(message: string, initialValue?: boolean): Promise<boolean>;
|
|
9
|
+
type SelectItem = {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function promptSelect(message: string, items: SelectItem[], defaultIndex?: number): Promise<string>;
|
|
14
|
+
export declare const spinner: ({ indicator, onCancel, output, cancelMessage, errorMessage, frames, delay, signal, ...opts }?: p.SpinnerOptions) => p.SpinnerResult;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,gBAAgB,CAAC;AAEpC,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAUD,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAClD,CAAC;AAEF,wBAAsB,UAAU,CAC9B,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED,wBAAsB,aAAa,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,UAAO,GAClB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,wBAAsB,YAAY,CAChC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,UAAU,EAAE,EACnB,YAAY,SAAI,GACf,OAAO,CAAC,MAAM,CAAC,CAejB;AAED,eAAO,MAAM,OAAO,sIAAY,CAAC"}
|
|
@@ -1,98 +1,10 @@
|
|
|
1
|
-
import { MCPServer } from "mcp-use
|
|
1
|
+
import { MCPServer } from "mcp-use";
|
|
2
2
|
|
|
3
|
-
// Create MCP server instance
|
|
4
3
|
const server = new MCPServer({
|
|
5
4
|
name: "{{PROJECT_NAME}}",
|
|
6
|
-
title: "{{PROJECT_NAME}}",
|
|
5
|
+
title: "{{PROJECT_NAME}}",
|
|
7
6
|
version: "1.0.0",
|
|
8
|
-
description: "
|
|
9
|
-
baseUrl: process.env.MCP_URL || "http://localhost:3000", // Full base URL (e.g., https://myserver.com)
|
|
10
|
-
favicon: "favicon.ico",
|
|
11
|
-
websiteUrl: "https://mcp-use.com", // Can be customized later
|
|
12
|
-
icons: [
|
|
13
|
-
{
|
|
14
|
-
src: "icon.svg",
|
|
15
|
-
mimeType: "image/svg+xml",
|
|
16
|
-
sizes: ["512x512"],
|
|
17
|
-
},
|
|
18
|
-
],
|
|
7
|
+
description: "A blank MCP server built with mcp-use",
|
|
19
8
|
});
|
|
20
9
|
|
|
21
|
-
|
|
22
|
-
* Define UI Widgets
|
|
23
|
-
* All React components in the `resources/` folder
|
|
24
|
-
* are automatically registered as MCP tools and resources.
|
|
25
|
-
*
|
|
26
|
-
* Just export widgetMetadata with description and Zod schema,
|
|
27
|
-
* and mcp-use handles the rest!
|
|
28
|
-
*
|
|
29
|
-
* Docs: https://mcp-use.com/docs/typescript/server/mcp-apps
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
* Define MCP tools
|
|
34
|
-
* Docs: https://mcp-use.com/docs/typescript/server/tools
|
|
35
|
-
*
|
|
36
|
-
* Response helpers (`text`, `object`, `image`, `markdown`, `html`, `error`,
|
|
37
|
-
* `widget`, ...) are exported from `mcp-use/server`.
|
|
38
|
-
|
|
39
|
-
import { text } from "mcp-use/server";
|
|
40
|
-
import { z } from "zod";
|
|
41
|
-
|
|
42
|
-
server.tool(
|
|
43
|
-
{
|
|
44
|
-
name: "fetch-weather",
|
|
45
|
-
description: "Fetch the weather for a city",
|
|
46
|
-
schema: z.object({
|
|
47
|
-
city: z.string().describe("The city to fetch the weather for"),
|
|
48
|
-
}),
|
|
49
|
-
},
|
|
50
|
-
async ({ city }) => {
|
|
51
|
-
const response = await fetch(`https://wttr.in/${city}?format=j1`);
|
|
52
|
-
const data: any = await response.json();
|
|
53
|
-
const current = data.current_condition[0];
|
|
54
|
-
return text(`The weather in ${city} is ${current.weatherDesc[0].value}. Temperature: ${current.temp_C}°C, Humidity: ${current.humidity}%`);
|
|
55
|
-
}
|
|
56
|
-
);
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/*
|
|
60
|
-
* Define MCP resources
|
|
61
|
-
* Docs: https://mcp-use.com/docs/typescript/server/resources
|
|
62
|
-
|
|
63
|
-
import { object } from "mcp-use/server";
|
|
64
|
-
|
|
65
|
-
server.resource({
|
|
66
|
-
name: "config",
|
|
67
|
-
uri: "config://settings",
|
|
68
|
-
description: "Server configuration",
|
|
69
|
-
}, async () => object({
|
|
70
|
-
theme: "dark",
|
|
71
|
-
language: "en",
|
|
72
|
-
}));
|
|
73
|
-
*/
|
|
74
|
-
|
|
75
|
-
/*
|
|
76
|
-
* Define MCP prompts
|
|
77
|
-
* Docs: https://mcp-use.com/docs/typescript/server/prompts
|
|
78
|
-
|
|
79
|
-
import { text } from "mcp-use/server";
|
|
80
|
-
import { z } from "zod";
|
|
81
|
-
|
|
82
|
-
server.prompt(
|
|
83
|
-
{
|
|
84
|
-
name: "review-code",
|
|
85
|
-
description: "Review code for best practices and potential issues",
|
|
86
|
-
schema: z.object({
|
|
87
|
-
code: z.string().describe("The code to review"),
|
|
88
|
-
}),
|
|
89
|
-
},
|
|
90
|
-
async ({ code }) => {
|
|
91
|
-
return text(`Please review this code:\n\n${code}`);
|
|
92
|
-
}
|
|
93
|
-
); */
|
|
94
|
-
|
|
95
|
-
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3000;
|
|
96
|
-
console.log(`Server running on port ${PORT}`);
|
|
97
|
-
// Start the server
|
|
98
|
-
server.listen(PORT);
|
|
10
|
+
export default server;
|
|
@@ -13,25 +13,16 @@
|
|
|
13
13
|
],
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"scripts": {
|
|
16
|
-
"postinstall": "mcp-use generate-types || exit 0",
|
|
17
16
|
"build": "mcp-use build",
|
|
18
17
|
"dev": "mcp-use dev",
|
|
19
18
|
"start": "mcp-use start",
|
|
20
19
|
"deploy": "mcp-use deploy"
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
|
-
"mcp-use": "workspace:*"
|
|
24
|
-
"react": "^19.2.4",
|
|
25
|
-
"react-dom": "^19.2.4",
|
|
26
|
-
"react-router": "^7.13.0",
|
|
27
|
-
"tailwindcss": "^4.2.0",
|
|
28
|
-
"zod": "4.3.5"
|
|
22
|
+
"mcp-use": "workspace:*"
|
|
29
23
|
},
|
|
30
24
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"
|
|
33
|
-
"@types/react-dom": "^19.2.3",
|
|
34
|
-
"tsx": "^4.21.0",
|
|
35
|
-
"typescript": "^5.9.3"
|
|
25
|
+
"@types/node": "^24.13.2",
|
|
26
|
+
"typescript": "7.0.1-rc"
|
|
36
27
|
}
|
|
37
28
|
}
|
|
@@ -1,137 +1,43 @@
|
|
|
1
|
-
import { MCPServer
|
|
1
|
+
import { MCPServer } from "mcp-use";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
+
const fruits = ["apple", "banana", "mango", "orange", "strawberry"];
|
|
5
|
+
|
|
6
|
+
const outputSchema = z.object({
|
|
7
|
+
query: z.string(),
|
|
8
|
+
items: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
9
|
+
});
|
|
10
|
+
|
|
4
11
|
const server = new MCPServer({
|
|
5
12
|
name: "{{PROJECT_NAME}}",
|
|
6
|
-
title: "{{PROJECT_NAME}}",
|
|
13
|
+
title: "{{PROJECT_NAME}}",
|
|
7
14
|
version: "1.0.0",
|
|
8
|
-
description: "MCP server with
|
|
9
|
-
instructions:
|
|
10
|
-
"Use search-tools to find fruit matches before calling get-fruit-details. Prefer the widget result when the user wants to browse or compare options visually.",
|
|
11
|
-
baseUrl: process.env.MCP_URL || "http://localhost:3000", // Full base URL (e.g., https://myserver.com)
|
|
12
|
-
favicon: "favicon.ico",
|
|
13
|
-
websiteUrl: "https://mcp-use.com", // Can be customized later
|
|
14
|
-
icons: [
|
|
15
|
-
{
|
|
16
|
-
src: "icon.svg",
|
|
17
|
-
mimeType: "image/svg+xml",
|
|
18
|
-
sizes: ["512x512"],
|
|
19
|
-
},
|
|
20
|
-
],
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* TOOL THAT RETURNS A WIDGET
|
|
25
|
-
* The `widget` config tells mcp-use which widget component to render.
|
|
26
|
-
* The `widget()` helper in the handler passes props to that component.
|
|
27
|
-
* Docs: https://mcp-use.com/docs/typescript/server/mcp-apps
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
// Fruits data — color values are Tailwind bg-[] classes used by the carousel UI
|
|
31
|
-
const fruits = [
|
|
32
|
-
{ fruit: "mango", color: "bg-[#FBF1E1] dark:bg-[#FBF1E1]/10" },
|
|
33
|
-
{ fruit: "pineapple", color: "bg-[#f8f0d9] dark:bg-[#f8f0d9]/10" },
|
|
34
|
-
{ fruit: "cherries", color: "bg-[#E2EDDC] dark:bg-[#E2EDDC]/10" },
|
|
35
|
-
{ fruit: "coconut", color: "bg-[#fbedd3] dark:bg-[#fbedd3]/10" },
|
|
36
|
-
{ fruit: "apricot", color: "bg-[#fee6ca] dark:bg-[#fee6ca]/10" },
|
|
37
|
-
{ fruit: "blueberry", color: "bg-[#e0e6e6] dark:bg-[#e0e6e6]/10" },
|
|
38
|
-
{ fruit: "grapes", color: "bg-[#f4ebe2] dark:bg-[#f4ebe2]/10" },
|
|
39
|
-
{ fruit: "watermelon", color: "bg-[#e6eddb] dark:bg-[#e6eddb]/10" },
|
|
40
|
-
{ fruit: "orange", color: "bg-[#fdebdf] dark:bg-[#fdebdf]/10" },
|
|
41
|
-
{ fruit: "avocado", color: "bg-[#ecefda] dark:bg-[#ecefda]/10" },
|
|
42
|
-
{ fruit: "apple", color: "bg-[#F9E7E4] dark:bg-[#F9E7E4]/10" },
|
|
43
|
-
{ fruit: "pear", color: "bg-[#f1f1cf] dark:bg-[#f1f1cf]/10" },
|
|
44
|
-
{ fruit: "plum", color: "bg-[#ece5ec] dark:bg-[#ece5ec]/10" },
|
|
45
|
-
{ fruit: "banana", color: "bg-[#fdf0dd] dark:bg-[#fdf0dd]/10" },
|
|
46
|
-
{ fruit: "strawberry", color: "bg-[#f7e6df] dark:bg-[#f7e6df]/10" },
|
|
47
|
-
{ fruit: "lemon", color: "bg-[#feeecd] dark:bg-[#feeecd]/10" },
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
// structuredContent schema for the search-tools result. The widget renders this
|
|
51
|
-
// data (it arrives as the widget's tool output / structuredContent).
|
|
52
|
-
const fruitRowSchema = z.object({
|
|
53
|
-
fruit: z.string(),
|
|
54
|
-
color: z.string(),
|
|
15
|
+
description: "An MCP Apps server built with mcp-use",
|
|
55
16
|
});
|
|
56
17
|
|
|
57
18
|
server.tool(
|
|
58
19
|
{
|
|
59
|
-
name: "search-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
// Hosts (e.g. ChatGPT) expect explicit hints. Use openWorldHint: true for HTTP/API calls;
|
|
66
|
-
// destructiveHint: true when deleting or overwriting user data.
|
|
67
|
-
annotations: {
|
|
68
|
-
readOnlyHint: true,
|
|
69
|
-
destructiveHint: false,
|
|
70
|
-
openWorldHint: false,
|
|
71
|
-
},
|
|
72
|
-
outputSchema: z.object({
|
|
73
|
-
query: z.string(),
|
|
74
|
-
results: z.array(fruitRowSchema),
|
|
75
|
-
}),
|
|
76
|
-
widget: {
|
|
20
|
+
name: "search-fruits",
|
|
21
|
+
description: "Search the fruit catalog",
|
|
22
|
+
inputSchema: z.object({ query: z.string().optional() }),
|
|
23
|
+
outputSchema,
|
|
24
|
+
view: {
|
|
77
25
|
name: "product-search-result",
|
|
78
|
-
|
|
79
|
-
|
|
26
|
+
description: "Fruit search results",
|
|
27
|
+
prefersBorder: true,
|
|
80
28
|
},
|
|
29
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
81
30
|
},
|
|
82
|
-
async ({ query }) => {
|
|
83
|
-
const
|
|
84
|
-
(
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// widget) and are type-checked against the outputSchema above.
|
|
92
|
-
return widget({
|
|
93
|
-
props: { query: query ?? "", results },
|
|
94
|
-
output: text(
|
|
95
|
-
`Found ${results.length} fruits matching "${query ?? "all"}"`
|
|
96
|
-
),
|
|
97
|
-
});
|
|
31
|
+
async ({ query = "" }) => {
|
|
32
|
+
const items = fruits
|
|
33
|
+
.filter((fruit) => fruit.includes(query.toLowerCase()))
|
|
34
|
+
.map((fruit) => ({ id: fruit, name: fruit }));
|
|
35
|
+
const data = { query, items };
|
|
36
|
+
return {
|
|
37
|
+
content: [{ type: "text", text: `Found ${items.length} fruits.` }],
|
|
38
|
+
structuredContent: data,
|
|
39
|
+
};
|
|
98
40
|
}
|
|
99
41
|
);
|
|
100
42
|
|
|
101
|
-
server
|
|
102
|
-
{
|
|
103
|
-
name: "get-fruit-details",
|
|
104
|
-
title: "Get fruit details",
|
|
105
|
-
description: "Get detailed information about a specific fruit",
|
|
106
|
-
schema: z.object({
|
|
107
|
-
fruit: z.string().describe("The fruit name"),
|
|
108
|
-
}),
|
|
109
|
-
annotations: {
|
|
110
|
-
readOnlyHint: true,
|
|
111
|
-
destructiveHint: false,
|
|
112
|
-
openWorldHint: false,
|
|
113
|
-
},
|
|
114
|
-
outputSchema: z.object({
|
|
115
|
-
fruit: z.string(),
|
|
116
|
-
color: z.string(),
|
|
117
|
-
facts: z.array(z.string()),
|
|
118
|
-
}),
|
|
119
|
-
},
|
|
120
|
-
async ({ fruit }) => {
|
|
121
|
-
const found = fruits.find(
|
|
122
|
-
(f) => f.fruit?.toLowerCase() === fruit?.toLowerCase()
|
|
123
|
-
);
|
|
124
|
-
return object({
|
|
125
|
-
fruit: found?.fruit ?? fruit,
|
|
126
|
-
color: found?.color ?? "unknown",
|
|
127
|
-
facts: [
|
|
128
|
-
`${fruit} is a delicious fruit`,
|
|
129
|
-
`Color: ${found?.color ?? "unknown"}`,
|
|
130
|
-
],
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
);
|
|
134
|
-
|
|
135
|
-
server.listen().then(() => {
|
|
136
|
-
console.log(`Server running`);
|
|
137
|
-
});
|
|
43
|
+
export default server;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mcp-use server",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"description": "MCP server with
|
|
5
|
+
"description": "MCP server with a standard MCP Apps view",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
@@ -12,12 +12,9 @@
|
|
|
12
12
|
"tools",
|
|
13
13
|
"resources",
|
|
14
14
|
"prompts",
|
|
15
|
-
"uiresource",
|
|
16
15
|
"ui",
|
|
17
16
|
"react",
|
|
18
|
-
"
|
|
19
|
-
"mcp-ui",
|
|
20
|
-
"apps-sdk"
|
|
17
|
+
"mcp-apps"
|
|
21
18
|
],
|
|
22
19
|
"main": "dist/index.js",
|
|
23
20
|
"scripts": {
|
|
@@ -25,22 +22,18 @@
|
|
|
25
22
|
"dev": "mcp-use dev",
|
|
26
23
|
"start": "mcp-use start",
|
|
27
24
|
"deploy": "mcp-use deploy",
|
|
28
|
-
"
|
|
25
|
+
"typecheck": "tsc --noEmit"
|
|
29
26
|
},
|
|
30
27
|
"dependencies": {
|
|
31
|
-
"@openai/apps-sdk-ui": "^0.2.1",
|
|
32
28
|
"mcp-use": "workspace:*",
|
|
33
29
|
"react": "^19.2.4",
|
|
34
30
|
"react-dom": "^19.2.4",
|
|
35
|
-
"
|
|
36
|
-
"tailwindcss": "^4.2.0",
|
|
37
|
-
"zod": "4.3.5"
|
|
31
|
+
"zod": "^4.4.3"
|
|
38
32
|
},
|
|
39
33
|
"devDependencies": {
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@types/react": "^19.2.
|
|
34
|
+
"@types/node": "^24.13.2",
|
|
35
|
+
"@types/react": "^19.2.17",
|
|
42
36
|
"@types/react-dom": "^19.2.3",
|
|
43
|
-
"
|
|
44
|
-
"typescript": "^5.9.3"
|
|
37
|
+
"typescript": "7.0.1-rc"
|
|
45
38
|
}
|
|
46
39
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useToolContext } from "mcp-use/react";
|
|
2
|
+
|
|
3
|
+
export default function ProductSearchResult() {
|
|
4
|
+
const view = useToolContext<"search-fruits">();
|
|
5
|
+
|
|
6
|
+
if (view.status === "pending" || view.status === "streaming") {
|
|
7
|
+
return (
|
|
8
|
+
<p>
|
|
9
|
+
Searching{view.toolInput?.query ? ` for ${view.toolInput.query}` : ""}…
|
|
10
|
+
</p>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
if (view.status === "cancelled") return <p>Search cancelled.</p>;
|
|
14
|
+
if (view.status === "error") return <p>{view.error.message}</p>;
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<main>
|
|
18
|
+
<h1>Fruit results</h1>
|
|
19
|
+
<ul>
|
|
20
|
+
{view.toolOutput.items.map((item) => (
|
|
21
|
+
<li key={item.id}>{item.name}</li>
|
|
22
|
+
))}
|
|
23
|
+
</ul>
|
|
24
|
+
</main>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "ES2024",
|
|
4
4
|
"jsx": "react-jsx",
|
|
5
|
-
"module": "
|
|
6
|
-
"moduleResolution": "
|
|
7
|
-
"
|
|
5
|
+
"module": "NodeNext",
|
|
6
|
+
"moduleResolution": "NodeNext",
|
|
7
|
+
"lib": ["ES2024", "DOM", "DOM.Iterable"],
|
|
8
8
|
"strict": true,
|
|
9
|
-
"outDir": "./dist",
|
|
10
|
-
"sourceMap": true,
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
9
|
"esModuleInterop": true,
|
|
13
10
|
"forceConsistentCasingInFileNames": true,
|
|
14
11
|
"skipLibCheck": true,
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"paths": {
|
|
19
|
-
"@/*": ["src/*"]
|
|
20
|
-
}
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"noUncheckedIndexedAccess": true,
|
|
14
|
+
"exactOptionalPropertyTypes": true
|
|
21
15
|
},
|
|
22
|
-
"include": ["index.ts", "src/**/*", "resources/**/*"
|
|
16
|
+
"include": ["index.ts", "src/**/*", "resources/**/*"],
|
|
23
17
|
"exclude": ["node_modules", "dist"]
|
|
24
18
|
}
|
|
@@ -1,114 +1,77 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { completable, MCPServer } from "mcp-use";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
|
-
// Create MCP server instance
|
|
5
4
|
const server = new MCPServer({
|
|
6
5
|
name: "{{PROJECT_NAME}}",
|
|
7
|
-
title: "{{PROJECT_NAME}}",
|
|
6
|
+
title: "{{PROJECT_NAME}}",
|
|
8
7
|
version: "1.0.0",
|
|
9
|
-
description: "
|
|
10
|
-
instructions:
|
|
11
|
-
"Use fetch-weather for current conditions, read config://settings before assuming user preferences, and use review-code only when the user asks for code feedback.",
|
|
12
|
-
baseUrl: process.env.MCP_URL || "http://localhost:3000", // Full base URL (e.g., https://myserver.com)
|
|
13
|
-
favicon: "favicon.ico",
|
|
14
|
-
websiteUrl: "https://mcp-use.com", // Can be customized later
|
|
15
|
-
icons: [
|
|
16
|
-
{
|
|
17
|
-
src: "icon.svg",
|
|
18
|
-
mimeType: "image/svg+xml",
|
|
19
|
-
sizes: ["512x512"],
|
|
20
|
-
},
|
|
21
|
-
],
|
|
8
|
+
description: "An MCP server built with mcp-use",
|
|
22
9
|
});
|
|
23
10
|
|
|
24
|
-
/**
|
|
25
|
-
* Define UI Widgets
|
|
26
|
-
* All React components in the `resources/` folder
|
|
27
|
-
* are automatically registered as MCP tools and resources.
|
|
28
|
-
*
|
|
29
|
-
* Just export widgetMetadata with description and Zod schema,
|
|
30
|
-
* and mcp-use handles the rest!
|
|
31
|
-
*
|
|
32
|
-
* Docs: https://manufact.com/docs/typescript/server/mcp-apps
|
|
33
|
-
*/
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
* Define MCP tools
|
|
37
|
-
* Docs: https://mcp-use.com/docs/typescript/server/tools
|
|
38
|
-
*/
|
|
39
11
|
server.tool(
|
|
40
12
|
{
|
|
41
13
|
name: "fetch-weather",
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
schema: z.object({
|
|
45
|
-
city: z.string().describe("The city to fetch the weather for"),
|
|
46
|
-
}),
|
|
47
|
-
// Declare outputSchema for any tool that returns structuredContent so clients
|
|
48
|
-
// can validate results and the model can reason about follow-up calls.
|
|
14
|
+
description: "Return demo weather for a city",
|
|
15
|
+
inputSchema: z.object({ city: z.string() }),
|
|
49
16
|
outputSchema: z.object({
|
|
50
|
-
city: z.string()
|
|
51
|
-
conditions: z.string()
|
|
52
|
-
temperature: z.string()
|
|
17
|
+
city: z.string(),
|
|
18
|
+
conditions: z.string(),
|
|
19
|
+
temperature: z.string(),
|
|
53
20
|
}),
|
|
54
|
-
|
|
55
|
-
annotations: {
|
|
56
|
-
readOnlyHint: true,
|
|
57
|
-
destructiveHint: false,
|
|
58
|
-
openWorldHint: false,
|
|
59
|
-
},
|
|
21
|
+
annotations: { readOnlyHint: true, openWorldHint: false },
|
|
60
22
|
},
|
|
61
|
-
// The returned object is type-checked against the `outputSchema` above:
|
|
62
|
-
// returning the wrong shape is a compile-time error.
|
|
63
23
|
async ({ city }) => {
|
|
64
|
-
|
|
24
|
+
const weather = { city, conditions: "sunny", temperature: "22°C" };
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: "text", text: JSON.stringify(weather) }],
|
|
27
|
+
structuredContent: weather,
|
|
28
|
+
};
|
|
65
29
|
}
|
|
66
30
|
);
|
|
67
31
|
|
|
68
|
-
/*
|
|
69
|
-
* Define MCP resources
|
|
70
|
-
* Docs: https://mcp-use.com/docs/typescript/server/resources
|
|
71
|
-
*/
|
|
72
32
|
server.resource(
|
|
73
33
|
{
|
|
74
|
-
name: "
|
|
34
|
+
name: "settings",
|
|
75
35
|
uri: "config://settings",
|
|
76
|
-
description: "
|
|
36
|
+
description: "Example application settings",
|
|
37
|
+
mimeType: "application/json",
|
|
77
38
|
},
|
|
78
|
-
async () =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
39
|
+
async (uri) => ({
|
|
40
|
+
contents: [
|
|
41
|
+
{
|
|
42
|
+
uri: uri.href,
|
|
43
|
+
mimeType: "application/json",
|
|
44
|
+
text: JSON.stringify({ theme: "dark", language: "en" }),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
})
|
|
83
48
|
);
|
|
84
49
|
|
|
85
|
-
/*
|
|
86
|
-
* Define MCP prompts
|
|
87
|
-
* Docs: https://mcp-use.com/docs/typescript/server/prompts
|
|
88
|
-
*/
|
|
89
50
|
server.prompt(
|
|
90
51
|
{
|
|
91
52
|
name: "review-code",
|
|
92
|
-
description: "Review code for
|
|
53
|
+
description: "Review code for correctness and maintainability",
|
|
93
54
|
schema: z.object({
|
|
94
55
|
language: completable(z.string(), [
|
|
95
|
-
"python",
|
|
96
|
-
"javascript",
|
|
97
56
|
"typescript",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
57
|
+
"javascript",
|
|
58
|
+
"python",
|
|
100
59
|
"go",
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
code: z.string().describe("The code to review"),
|
|
60
|
+
]),
|
|
61
|
+
code: z.string(),
|
|
104
62
|
}),
|
|
105
63
|
},
|
|
106
|
-
async ({ language, code }) => {
|
|
107
|
-
|
|
108
|
-
|
|
64
|
+
async ({ language, code }) => ({
|
|
65
|
+
messages: [
|
|
66
|
+
{
|
|
67
|
+
role: "user",
|
|
68
|
+
content: {
|
|
69
|
+
type: "text",
|
|
70
|
+
text: `Review this ${language} code:\n\n${code}`,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
})
|
|
109
75
|
);
|
|
110
76
|
|
|
111
|
-
|
|
112
|
-
console.log(`Server running on port ${PORT}`);
|
|
113
|
-
// Start the server
|
|
114
|
-
server.listen(PORT);
|
|
77
|
+
export default server;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "mcp-use server",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"version": "1.0.0",
|
|
5
|
-
"description": "MCP server with starter tools and
|
|
5
|
+
"description": "MCP server with starter tools, resources, and prompts",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"keywords": [
|
|
@@ -12,16 +12,10 @@
|
|
|
12
12
|
"tools",
|
|
13
13
|
"resources",
|
|
14
14
|
"prompts",
|
|
15
|
-
"
|
|
16
|
-
"ui",
|
|
17
|
-
"react",
|
|
18
|
-
"widgets",
|
|
19
|
-
"mcp-ui",
|
|
20
|
-
"apps-sdk"
|
|
15
|
+
"mcp-use"
|
|
21
16
|
],
|
|
22
17
|
"main": "dist/index.js",
|
|
23
18
|
"scripts": {
|
|
24
|
-
"postinstall": "mcp-use generate-types || exit 0",
|
|
25
19
|
"build": "mcp-use build",
|
|
26
20
|
"dev": "mcp-use dev",
|
|
27
21
|
"start": "mcp-use start",
|
|
@@ -29,17 +23,10 @@
|
|
|
29
23
|
},
|
|
30
24
|
"dependencies": {
|
|
31
25
|
"mcp-use": "workspace:*",
|
|
32
|
-
"
|
|
33
|
-
"react-dom": "^19.2.4",
|
|
34
|
-
"react-router": "^7.13.0",
|
|
35
|
-
"tailwindcss": "^4.2.0",
|
|
36
|
-
"zod": "4.3.5"
|
|
26
|
+
"zod": "^4.4.3"
|
|
37
27
|
},
|
|
38
28
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^
|
|
40
|
-
"
|
|
41
|
-
"@types/react-dom": "^19.2.3",
|
|
42
|
-
"tsx": "^4.21.0",
|
|
43
|
-
"typescript": "^5.9.3"
|
|
29
|
+
"@types/node": "^24.13.2",
|
|
30
|
+
"typescript": "7.0.1-rc"
|
|
44
31
|
}
|
|
45
32
|
}
|