create-mcp-use-app 0.9.2 → 0.9.3
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.
|
@@ -88,7 +88,7 @@ const propSchema = z.object({
|
|
|
88
88
|
|
|
89
89
|
export const widgetMetadata: WidgetMetadata = {
|
|
90
90
|
description: 'My widget description',
|
|
91
|
-
|
|
91
|
+
props: propSchema,
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const MyWidget: React.FC = () => {
|
|
@@ -146,7 +146,7 @@ const propSchema = z.object({
|
|
|
146
146
|
|
|
147
147
|
export const widgetMetadata: WidgetMetadata = {
|
|
148
148
|
description: 'Display user information',
|
|
149
|
-
|
|
149
|
+
props: propSchema,
|
|
150
150
|
};
|
|
151
151
|
```
|
|
152
152
|
|
|
@@ -295,7 +295,7 @@ const propSchema = z.object({
|
|
|
295
295
|
|
|
296
296
|
export const widgetMetadata: WidgetMetadata = {
|
|
297
297
|
description: 'Display a message',
|
|
298
|
-
|
|
298
|
+
props: propSchema,
|
|
299
299
|
};
|
|
300
300
|
|
|
301
301
|
type Props = z.infer<typeof propSchema>;
|
|
@@ -320,11 +320,13 @@ export default MyWidget;
|
|
|
320
320
|
You can mix Apps SDK widgets with regular MCP tools:
|
|
321
321
|
|
|
322
322
|
```typescript
|
|
323
|
+
import { text } from 'mcp-use/server';
|
|
324
|
+
|
|
323
325
|
server.tool({
|
|
324
326
|
name: 'get-data',
|
|
325
327
|
description: 'Fetch data from API',
|
|
326
328
|
cb: async () => {
|
|
327
|
-
return
|
|
329
|
+
return text('Data');
|
|
328
330
|
},
|
|
329
331
|
});
|
|
330
332
|
```
|
|
@@ -76,9 +76,10 @@ npm start
|
|
|
76
76
|
### Simple Widget Registration
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
import {
|
|
79
|
+
import { MCPServer } from 'mcp-use/server'
|
|
80
80
|
|
|
81
|
-
const server =
|
|
81
|
+
const server = new MCPServer({
|
|
82
|
+
name: 'my-server',
|
|
82
83
|
version: '1.0.0',
|
|
83
84
|
description: 'Server with UIResource widgets',
|
|
84
85
|
})
|
|
@@ -26,14 +26,16 @@ This starter template demonstrates all major MCP features:
|
|
|
26
26
|
### 1. Traditional Tools
|
|
27
27
|
|
|
28
28
|
```typescript
|
|
29
|
+
import { text } from 'mcp-use/server';
|
|
30
|
+
|
|
29
31
|
server.tool({
|
|
30
32
|
name: 'greet',
|
|
31
33
|
description: 'Greet someone by name',
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
34
|
+
schema: z.object({name:z.string()}),
|
|
35
|
+
}, async ({ name }) => {
|
|
36
|
+
return text(`Hello, ${name}!`)
|
|
35
37
|
},
|
|
36
|
-
|
|
38
|
+
)
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
### 2. Resources
|
|
@@ -265,14 +267,14 @@ await client.getPrompt('review-code', { code: 'const x = 1;' })
|
|
|
265
267
|
server.tool({
|
|
266
268
|
name: 'my-tool',
|
|
267
269
|
description: 'My custom tool',
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
schema: z.object({
|
|
271
|
+
param: z.string(),
|
|
272
|
+
})
|
|
273
|
+
}, async ({ param }) => {
|
|
270
274
|
// Your logic here
|
|
271
|
-
return
|
|
272
|
-
content: [{ type: 'text', text: `Result: ${param}` }],
|
|
273
|
-
}
|
|
275
|
+
return text(param)
|
|
274
276
|
},
|
|
275
|
-
|
|
277
|
+
)
|
|
276
278
|
```
|
|
277
279
|
|
|
278
280
|
### Adding New React Widgets
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { MCPServer } from "mcp-use/server";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
|
|
3
4
|
// Create MCP server instance
|
|
4
5
|
const server = new MCPServer({
|
|
@@ -34,10 +35,11 @@ server.tool(
|
|
|
34
35
|
{
|
|
35
36
|
name: "fetch-weather",
|
|
36
37
|
description: "Fetch the weather for a city",
|
|
37
|
-
|
|
38
|
+
schema: z.object({
|
|
39
|
+
city: z.string().describe("The city to fetch the weather for"),
|
|
40
|
+
}),
|
|
38
41
|
},
|
|
39
|
-
async (
|
|
40
|
-
const city = params.city as string;
|
|
42
|
+
async ({ city }) => {
|
|
41
43
|
const response = await fetch(`https://wttr.in/${city}?format=j1`);
|
|
42
44
|
const data: any = await response.json();
|
|
43
45
|
const current = data.current_condition[0];
|