Skip to content

Commit 999a2a4

Browse files
v0.2 (#4)
1 parent 59959bc commit 999a2a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5352
-591
lines changed

docs/content/docs/concepts/architecture.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

docs/content/docs/concepts/example-prompt.ts

Lines changed: 0 additions & 51 deletions
This file was deleted.

docs/content/docs/concepts/example-resource.ts

Lines changed: 0 additions & 41 deletions
This file was deleted.

docs/content/docs/concepts/example-tool.ts

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"title": "Concepts",
33
"pages": [
4-
"architecture",
5-
"resources",
6-
"prompts",
7-
"tools",
8-
"transports"
4+
"./resources/index",
5+
"./prompts/index",
6+
"./tools/index",
7+
"./muppet/index",
8+
"./transports/index"
99
]
1010
}

docs/content/docs/concepts/transport-stdio.ts renamed to docs/content/docs/concepts/muppet/example-bridge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
22
import { Hono } from "hono";
3-
import { bridge, muppet } from "muppet";
3+
import { muppet, bridge } from "muppet";
44

55
const app = new Hono();
66

77
// Define your tools, prompts, and resources here
88
// ...
99

10-
muppet(app, {
10+
const instance = muppet(app, {
1111
name: "My Muppet",
1212
version: "1.0.0",
1313
}).then((mcp) => {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Hono } from "hono";
2+
import { muppet } from "muppet";
3+
4+
const app = new Hono();
5+
6+
// Define your tools, prompts, and resources here
7+
// ...
8+
9+
const instance = muppet(app, {
10+
name: "My Muppet",
11+
version: "1.0.0",
12+
});
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
title: MCP & Bridge
3+
description: Creating the MCP instance of your app
4+
---
5+
6+
import { TypeTable } from 'fumadocs-ui/components/type-table';
7+
import { DynamicCodeBlock } from 'fumadocs-ui/components/dynamic-codeblock';
8+
import fs from 'fs';
9+
10+
## Muppet
11+
12+
Now that you have defined your tools and prompts, you can create the MCP instance of your app. This is done using the `muppet` function. This function takes the `app` instance and an configurtions object as arguments.
13+
14+
<DynamicCodeBlock lang="ts" code={fs.readFileSync("./content/docs/concepts/muppet/example-muppet.ts", "utf-8")} />
15+
16+
The `muppet` function takes the following configurations
17+
18+
<TypeTable
19+
type={{
20+
name: {
21+
description: 'The name of the MCP server. This is used to identify the server by the MCP Client.',
22+
type: 'string',
23+
required: true,
24+
},
25+
version: {
26+
description: 'The version of the MCP server. This is used to identify the server by the MCP Client.',
27+
type: 'string',
28+
required: true,
29+
},
30+
logger: {
31+
description: 'A logger instance to use for logging. It uses pino under the hood, so you can use any pino compatible logger.',
32+
type: 'number',
33+
},
34+
resources: {
35+
type: "Record<string, ResourceFetcherFn>",
36+
},
37+
events: {
38+
type: "Emitter<ClientToServerNotifications>"
39+
}
40+
}}
41+
/>
42+
43+
## Bridge
44+
45+
Now let's create a bridge between the LLM and your server. This is done using the `bridge` function. Think of this like [Bifröst](https://en.wikipedia.org/wiki/Bifr%C3%B6st), it connects the LLM using the [transport layer](/docs/concepts/transports) to your server.
46+
47+
This takes in your muppet instance and the transport layer you wanna use.
48+
49+
<DynamicCodeBlock lang="ts" code={fs.readFileSync("./content/docs/concepts/muppet/example-bridge.ts", "utf-8")} />
50+
51+
You can check out other transport layers [here](/docs/concepts/transports).

docs/content/docs/concepts/prompts.mdx

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Hono } from "hono";
2+
import { describePrompt, mValidator, type PromptResponseType } from "muppet";
3+
import z from "zod";
4+
5+
const app = new Hono();
6+
7+
app.post(
8+
"/explain-like-im-5",
9+
describePrompt({
10+
name: "Explain like I'm 5",
11+
description: "A prompt to explain an advance topic to a 5 year old",
12+
completion: ({ name, value }) => [
13+
"quantum physics",
14+
"machine learning",
15+
"natural language processing",
16+
"artificial intelligence",
17+
],
18+
}),
19+
mValidator(
20+
"json",
21+
z.object({
22+
topic: z.string(),
23+
}),
24+
),
25+
(c) => {
26+
const { topic } = c.req.valid("json");
27+
return c.json<PromptResponseType>([
28+
{
29+
role: "user",
30+
content: {
31+
type: "text",
32+
text: `Explain ${topic} to me like I'm five`,
33+
},
34+
},
35+
]);
36+
},
37+
);

0 commit comments

Comments
 (0)