@ounie/mcp 0.3.1 → 0.6.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 +30 -1
- package/dist/api.d.ts +91 -1
- package/dist/api.js +64 -2
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +328 -14
- package/dist/index.js.map +1 -1
- package/dist/ui-resources.d.ts +22 -0
- package/dist/ui-resources.js +206 -0
- package/dist/ui-resources.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ It speaks MCP over **stdio** and calls the Ounie REST API on your behalf using a
|
|
|
17
17
|
| `ounie_add_to_brain` | `brainId`, `content`, `title?`, `mode?`, `sourceUrl?` | Save a chat result (or any text). `mode:'synthesize'` (default) connects it into the wiki+graph and makes it citable; `mode:'note'` stores it verbatim. |
|
|
18
18
|
| `ounie_add_note` | `brainId`, `title`, `body` | Save a text note as a new source (verbatim). |
|
|
19
19
|
| `ounie_add_link` | `brainId`, `url` | Save a web link as a new source. |
|
|
20
|
+
| `ounie_save_asset` | `brainId`, `title`, `description?`, `type?`, `status?`, `links?`, `tags?`, `client?` | File an **output** made with the brain (carousel, article, ad…) into its Assets library. The opposite of `ounie_add_to_brain`: knowledge IN vs output OUT — assets are never ingested, never cited, cost nothing. Owner/editor only. |
|
|
20
21
|
| `ounie_search` | `brainId`, `query` | Retrieve & summarize relevant saved sources. |
|
|
21
22
|
| `ounie_get_context` | `brainId`, `query` | Retrieve the raw matching wiki pages **without** generating an answer — your assistant reasons over them and cites by `slug`. Cheaper/faster than `ounie_ask_brain`. |
|
|
22
23
|
|
|
@@ -32,6 +33,30 @@ default:
|
|
|
32
33
|
> call `ounie_get_context`, read the returned pages, and write the answer yourself, citing
|
|
33
34
|
> pages inline as `[[slug]]`. Only use `ounie_ask_brain` if I explicitly ask Ounie to answer.
|
|
34
35
|
|
|
36
|
+
## UI templates (ChatGPT app / MCP Apps)
|
|
37
|
+
|
|
38
|
+
Beyond tools, the server advertises the **`resources`** capability and serves a small set of
|
|
39
|
+
self-contained HTML **UI templates** (`ui://ounie/<name>.html`) so **Apps-SDK hosts** (ChatGPT,
|
|
40
|
+
MCP Inspector) render interactive cards inline. Non-Apps clients (Claude.ai, Claude Desktop,
|
|
41
|
+
Cursor) ignore resources and just use the text in each tool result — no behaviour change.
|
|
42
|
+
|
|
43
|
+
| Template | Tool(s) | What it shows |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| `ui://ounie/brain-picker.html` | `ounie_list_brains` | Grid of brains; tap to select. |
|
|
46
|
+
| `ui://ounie/source-list.html` | `ounie_search` | Ranked matching sources with links. |
|
|
47
|
+
| `ui://ounie/saved-toast.html` | `ounie_add_note`, `ounie_add_link` | Save confirmation. |
|
|
48
|
+
|
|
49
|
+
`ounie_get_context` and `ounie_ask_brain` are **text-only by design** (no card): the host model
|
|
50
|
+
writes the answer from the returned pages. (`get_context` briefly had an answer card; it was
|
|
51
|
+
dropped because the card sat above the streamed answer as an empty frame — the text answer is the
|
|
52
|
+
output.) Tool descriptors also carry MCP **annotations** (`readOnlyHint`/`destructiveHint`/
|
|
53
|
+
`openWorldHint`) so hosts label reads correctly.
|
|
54
|
+
|
|
55
|
+
The templates are defined once in `web/` and **vendored** here as `src/ui-resources.ts`
|
|
56
|
+
(hand-synced copy, like the tool list) since this package can't import from `web/`. The hosted
|
|
57
|
+
`POST /api/mcp` is also a submitted **ChatGPT app** (OpenAI Apps directory); domain verification
|
|
58
|
+
is served from `web/src/app/.well-known/openai-apps-challenge`.
|
|
59
|
+
|
|
35
60
|
## Get an API key
|
|
36
61
|
|
|
37
62
|
Generate a personal key (`ounie_live_…`) at **Settings → API keys**
|
|
@@ -128,9 +153,13 @@ mcp/
|
|
|
128
153
|
├── tsconfig.json # NodeNext, strict, outDir dist
|
|
129
154
|
├── README.md
|
|
130
155
|
└── src/
|
|
131
|
-
├── index.ts # MCP stdio server +
|
|
156
|
+
├── index.ts # MCP stdio server: tools (+ annotations) & resources
|
|
157
|
+
├── ui-resources.ts # vendored UI templates (ui://ounie/*) — sync w/ web
|
|
132
158
|
└── api.ts # typed fetch client for the Ounie REST API
|
|
133
159
|
```
|
|
134
160
|
|
|
161
|
+
When you change a UI template or the tool spec, update **both** `web/` and this package
|
|
162
|
+
(`src/index.ts` tools, `src/ui-resources.ts` templates) — they're hand-synced.
|
|
163
|
+
|
|
135
164
|
`ounie_search` currently maps onto `ounie_ask_brain` with a retrieval-oriented prompt; it
|
|
136
165
|
will repoint to a dedicated search endpoint when one ships.
|
package/dist/api.d.ts
CHANGED
|
@@ -12,6 +12,22 @@ export interface Brain {
|
|
|
12
12
|
emoji?: string;
|
|
13
13
|
sourceCount?: number;
|
|
14
14
|
}
|
|
15
|
+
/** Card shape returned by GET /api/public/brains (the Explore feed). */
|
|
16
|
+
export interface PublicBrainCardLite {
|
|
17
|
+
id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
slug: string;
|
|
20
|
+
description: string | null;
|
|
21
|
+
emoji: string;
|
|
22
|
+
ownerUsername: string | null;
|
|
23
|
+
sourceCount: number;
|
|
24
|
+
starCount: number;
|
|
25
|
+
forkable: boolean;
|
|
26
|
+
listingModel: "per_question" | "free_preview" | null;
|
|
27
|
+
priceCredits: number | null;
|
|
28
|
+
freePreview: number | null;
|
|
29
|
+
x402Enabled: boolean | null;
|
|
30
|
+
}
|
|
15
31
|
export interface Source {
|
|
16
32
|
id: string;
|
|
17
33
|
type: "link" | "note" | "file";
|
|
@@ -43,7 +59,13 @@ export interface OunieClientOptions {
|
|
|
43
59
|
}
|
|
44
60
|
export declare class OunieApiError extends Error {
|
|
45
61
|
readonly status: number;
|
|
46
|
-
|
|
62
|
+
/** Raw response body text — error payloads (e.g. payment_required) are
|
|
63
|
+
* JSON; callers can parse this to react to specific reasons. */
|
|
64
|
+
readonly body: string;
|
|
65
|
+
constructor(status: number, message: string,
|
|
66
|
+
/** Raw response body text — error payloads (e.g. payment_required) are
|
|
67
|
+
* JSON; callers can parse this to react to specific reasons. */
|
|
68
|
+
body?: string);
|
|
47
69
|
}
|
|
48
70
|
export declare class OunieClient {
|
|
49
71
|
private readonly baseUrl;
|
|
@@ -53,8 +75,54 @@ export declare class OunieClient {
|
|
|
53
75
|
private request;
|
|
54
76
|
/** GET /api/brains -> { brains: [...] } (Phase 4 endpoint). */
|
|
55
77
|
listBrains(): Promise<Brain[]>;
|
|
78
|
+
/**
|
|
79
|
+
* GET /api/public/brains — the public Explore feed (other people's public
|
|
80
|
+
* brains, incl. paid marketplace listings). Anonymous-safe endpoint; the
|
|
81
|
+
* Bearer key only hydrates viewer engagement.
|
|
82
|
+
*/
|
|
83
|
+
exploreBrains(opts?: {
|
|
84
|
+
q?: string;
|
|
85
|
+
filter?: "all" | "free" | "paid" | "forkable";
|
|
86
|
+
sort?: "new" | "popular" | "price";
|
|
87
|
+
limit?: number;
|
|
88
|
+
}): Promise<{
|
|
89
|
+
brains: PublicBrainCardLite[];
|
|
90
|
+
hasMore: boolean;
|
|
91
|
+
}>;
|
|
92
|
+
/**
|
|
93
|
+
* POST /api/listing/:id/ask — ask a PAID marketplace brain, spending the
|
|
94
|
+
* user's prepaid credits (or a remaining free preview). A thin answer is
|
|
95
|
+
* never charged. 402 bodies: needs_credits | paid-listing gates.
|
|
96
|
+
*/
|
|
97
|
+
askListing(brainId: string, question: string): Promise<{
|
|
98
|
+
id?: string;
|
|
99
|
+
answer: string;
|
|
100
|
+
answerHtml?: string;
|
|
101
|
+
citations: {
|
|
102
|
+
slug: string;
|
|
103
|
+
title: string;
|
|
104
|
+
url: string;
|
|
105
|
+
}[];
|
|
106
|
+
thin: boolean;
|
|
107
|
+
}>;
|
|
56
108
|
/** POST /api/brains/:id/ask -> AskAnswer. */
|
|
57
109
|
ask(brainId: string, question: string): Promise<AskAnswer>;
|
|
110
|
+
/** POST /api/v1/brain-sets/:id/ask -> blended, dual-cited answer (Team only). */
|
|
111
|
+
askBrainSet(setId: string, question: string): Promise<{
|
|
112
|
+
answer: string;
|
|
113
|
+
citations: {
|
|
114
|
+
brain: {
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
kind: "primary" | "advisor";
|
|
118
|
+
};
|
|
119
|
+
slug: string;
|
|
120
|
+
title: string;
|
|
121
|
+
url: string | null;
|
|
122
|
+
}[];
|
|
123
|
+
thin: boolean;
|
|
124
|
+
advisorContributed: boolean;
|
|
125
|
+
}>;
|
|
58
126
|
/**
|
|
59
127
|
* POST /api/brains/:id/context -> raw retrieved wiki pages, NO answer LLM.
|
|
60
128
|
* The caller's own model reasons over `contextText` and cites by `slug`.
|
|
@@ -84,6 +152,28 @@ export declare class OunieClient {
|
|
|
84
152
|
sourceUrl?: string;
|
|
85
153
|
externalId?: string;
|
|
86
154
|
}): Promise<Source>;
|
|
155
|
+
/**
|
|
156
|
+
* File an OUTPUT made with the brain into its Assets library (never
|
|
157
|
+
* ingested, never cited, zero cost — the opposite direction of addToBrain).
|
|
158
|
+
* POST /api/brains/:id/assets -> { asset }. Owner/editor only.
|
|
159
|
+
*/
|
|
160
|
+
saveAsset(brainId: string, input: {
|
|
161
|
+
title: string;
|
|
162
|
+
description?: string;
|
|
163
|
+
type?: string;
|
|
164
|
+
status?: string;
|
|
165
|
+
links?: {
|
|
166
|
+
url: string;
|
|
167
|
+
label?: string;
|
|
168
|
+
}[];
|
|
169
|
+
tags?: string[];
|
|
170
|
+
client?: string;
|
|
171
|
+
}): Promise<{
|
|
172
|
+
id: string;
|
|
173
|
+
title: string;
|
|
174
|
+
type: string;
|
|
175
|
+
status: string;
|
|
176
|
+
}>;
|
|
87
177
|
/**
|
|
88
178
|
* Search a brain. There is no dedicated search endpoint yet, so this maps to
|
|
89
179
|
* `ask` with a retrieval-oriented prompt. Swap to a real `/api/brains/:id/search`
|
package/dist/api.js
CHANGED
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
export class OunieApiError extends Error {
|
|
9
9
|
status;
|
|
10
|
-
|
|
10
|
+
body;
|
|
11
|
+
constructor(status, message,
|
|
12
|
+
/** Raw response body text — error payloads (e.g. payment_required) are
|
|
13
|
+
* JSON; callers can parse this to react to specific reasons. */
|
|
14
|
+
body = "") {
|
|
11
15
|
super(`Ounie API ${status}: ${message}`);
|
|
12
16
|
this.status = status;
|
|
17
|
+
this.body = body;
|
|
13
18
|
this.name = "OunieApiError";
|
|
14
19
|
}
|
|
15
20
|
}
|
|
@@ -38,7 +43,7 @@ export class OunieClient {
|
|
|
38
43
|
});
|
|
39
44
|
if (!res.ok) {
|
|
40
45
|
const text = await res.text().catch(() => "");
|
|
41
|
-
throw new OunieApiError(res.status, text || res.statusText);
|
|
46
|
+
throw new OunieApiError(res.status, text || res.statusText, text);
|
|
42
47
|
}
|
|
43
48
|
const text = await res.text();
|
|
44
49
|
return (text ? JSON.parse(text) : null);
|
|
@@ -48,10 +53,44 @@ export class OunieClient {
|
|
|
48
53
|
const data = await this.request("/api/brains");
|
|
49
54
|
return data?.brains ?? [];
|
|
50
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* GET /api/public/brains — the public Explore feed (other people's public
|
|
58
|
+
* brains, incl. paid marketplace listings). Anonymous-safe endpoint; the
|
|
59
|
+
* Bearer key only hydrates viewer engagement.
|
|
60
|
+
*/
|
|
61
|
+
async exploreBrains(opts = {}) {
|
|
62
|
+
const params = new URLSearchParams();
|
|
63
|
+
if (opts.q)
|
|
64
|
+
params.set("q", opts.q);
|
|
65
|
+
if (opts.filter)
|
|
66
|
+
params.set("filter", opts.filter);
|
|
67
|
+
if (opts.sort)
|
|
68
|
+
params.set("sort", opts.sort);
|
|
69
|
+
if (opts.limit)
|
|
70
|
+
params.set("limit", String(opts.limit));
|
|
71
|
+
const qs = params.toString();
|
|
72
|
+
const data = await this.request(`/api/public/brains${qs ? `?${qs}` : ""}`);
|
|
73
|
+
return { brains: data?.brains ?? [], hasMore: data?.hasMore ?? false };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* POST /api/listing/:id/ask — ask a PAID marketplace brain, spending the
|
|
77
|
+
* user's prepaid credits (or a remaining free preview). A thin answer is
|
|
78
|
+
* never charged. 402 bodies: needs_credits | paid-listing gates.
|
|
79
|
+
*/
|
|
80
|
+
async askListing(brainId, question) {
|
|
81
|
+
return this.request(`/api/listing/${encodeURIComponent(brainId)}/ask`, {
|
|
82
|
+
method: "POST",
|
|
83
|
+
body: { question },
|
|
84
|
+
});
|
|
85
|
+
}
|
|
51
86
|
/** POST /api/brains/:id/ask -> AskAnswer. */
|
|
52
87
|
async ask(brainId, question) {
|
|
53
88
|
return this.request(`/api/brains/${encodeURIComponent(brainId)}/ask`, { method: "POST", body: { question } });
|
|
54
89
|
}
|
|
90
|
+
/** POST /api/v1/brain-sets/:id/ask -> blended, dual-cited answer (Team only). */
|
|
91
|
+
async askBrainSet(setId, question) {
|
|
92
|
+
return this.request(`/api/v1/brain-sets/${encodeURIComponent(setId)}/ask`, { method: "POST", body: { question } });
|
|
93
|
+
}
|
|
55
94
|
/**
|
|
56
95
|
* POST /api/brains/:id/context -> raw retrieved wiki pages, NO answer LLM.
|
|
57
96
|
* The caller's own model reasons over `contextText` and cites by `slug`.
|
|
@@ -100,6 +139,29 @@ export class OunieClient {
|
|
|
100
139
|
});
|
|
101
140
|
return data.source;
|
|
102
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* File an OUTPUT made with the brain into its Assets library (never
|
|
144
|
+
* ingested, never cited, zero cost — the opposite direction of addToBrain).
|
|
145
|
+
* POST /api/brains/:id/assets -> { asset }. Owner/editor only.
|
|
146
|
+
*/
|
|
147
|
+
async saveAsset(brainId, input) {
|
|
148
|
+
const data = await this.request(`/api/brains/${encodeURIComponent(brainId)}/assets`, {
|
|
149
|
+
method: "POST",
|
|
150
|
+
body: {
|
|
151
|
+
title: input.title,
|
|
152
|
+
description: input.description,
|
|
153
|
+
type: input.type,
|
|
154
|
+
status: input.status,
|
|
155
|
+
links: input.links,
|
|
156
|
+
tags: input.tags,
|
|
157
|
+
madeWith: {
|
|
158
|
+
surface: "mcp",
|
|
159
|
+
...(input.client ? { client: input.client } : {}),
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
return data.asset;
|
|
164
|
+
}
|
|
103
165
|
/**
|
|
104
166
|
* Search a brain. There is no dedicated search endpoint yet, so this maps to
|
|
105
167
|
* `ask` with a retrieval-oriented prompt. Swap to a real `/api/brains/:id/search`
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8DH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAEpB;IAIA;IALlB,YACkB,MAAc,EAC9B,OAAe;IACf;qEACiE;IACjD,OAAe,EAAE;QAEjC,KAAK,CAAC,aAAa,MAAM,KAAK,OAAO,EAAE,CAAC,CAAC;QANzB,WAAM,GAAN,MAAM,CAAQ;QAId,SAAI,GAAJ,IAAI,CAAa;QAGjC,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,OAAO,WAAW;IACL,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,SAAS,CAAe;IAEzC,YAAY,IAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,OAAO,IAAI,mBAAmB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC;IAC3C,CAAC;IAEO,KAAK,CAAC,OAAO,CACnB,IAAY,EACZ,OAA4C,EAAE;QAE9C,MAAM,GAAG,GAAG,GA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OAAO,EAAE,KAAK;oBACd,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;iBAClD;aACF;SACF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,KAAa;QACzC,OAAO,IAAI,CAAC,GAAG,CACb,OAAO,EACP,2DAA2D,KAAK,EAAE,CACnE,CAAC;IACJ,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,11 +8,13 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Tools:
|
|
10
10
|
* - ounie_list_brains
|
|
11
|
-
* -
|
|
11
|
+
* - ounie_explore_brains (q?, filter?, sort?, limit?) discover public/paid brains
|
|
12
|
+
* - ounie_ask_brain (brainId, question, payWithCredits?)
|
|
12
13
|
* - ounie_add_note (brainId, title, body)
|
|
13
14
|
* - ounie_add_link (brainId, url)
|
|
14
15
|
* - ounie_add_to_brain (brainId, content, ...)
|
|
15
|
-
* -
|
|
16
|
+
* - ounie_save_asset (brainId, title, ...) file an OUTPUT (never ingested)
|
|
17
|
+
* - ounie_search (brainId, query, payWithCredits?)
|
|
16
18
|
* - ounie_get_context (brainId, query) raw pages, no answer LLM
|
|
17
19
|
*/
|
|
18
20
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -8,17 +8,30 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Tools:
|
|
10
10
|
* - ounie_list_brains
|
|
11
|
-
* -
|
|
11
|
+
* - ounie_explore_brains (q?, filter?, sort?, limit?) discover public/paid brains
|
|
12
|
+
* - ounie_ask_brain (brainId, question, payWithCredits?)
|
|
12
13
|
* - ounie_add_note (brainId, title, body)
|
|
13
14
|
* - ounie_add_link (brainId, url)
|
|
14
15
|
* - ounie_add_to_brain (brainId, content, ...)
|
|
15
|
-
* -
|
|
16
|
+
* - ounie_save_asset (brainId, title, ...) file an OUTPUT (never ingested)
|
|
17
|
+
* - ounie_search (brainId, query, payWithCredits?)
|
|
16
18
|
* - ounie_get_context (brainId, query) raw pages, no answer LLM
|
|
17
19
|
*/
|
|
18
20
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
19
21
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
20
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
21
|
-
import { OunieClient } from "./api.js";
|
|
22
|
+
import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
23
|
+
import { OunieApiError, OunieClient } from "./api.js";
|
|
24
|
+
import { listUiResources, readUiResource } from "./ui-resources.js";
|
|
25
|
+
/** Descriptor `_meta` naming a tool's UI output template (MCP Apps + ChatGPT). */
|
|
26
|
+
function uiMeta(name, invoking, invoked) {
|
|
27
|
+
const uri = `ui://ounie/${name}.html`;
|
|
28
|
+
return {
|
|
29
|
+
ui: { resourceUri: uri },
|
|
30
|
+
"openai/outputTemplate": uri,
|
|
31
|
+
"openai/toolInvocation/invoking": invoking,
|
|
32
|
+
"openai/toolInvocation/invoked": invoked,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
22
35
|
// --- Config --------------------------------------------------------------------
|
|
23
36
|
const API_KEY = process.env.OUNIE_API_KEY;
|
|
24
37
|
const BASE_URL = process.env.OUNIE_BASE_URL ?? "https://ounie.com";
|
|
@@ -29,7 +42,14 @@ if (!API_KEY) {
|
|
|
29
42
|
}
|
|
30
43
|
const client = new OunieClient({ apiKey: API_KEY, baseUrl: BASE_URL });
|
|
31
44
|
// --- Tool definitions ----------------------------------------------------------
|
|
32
|
-
|
|
45
|
+
// Shared opt-in flag for the marketplace credits rail (paid listings).
|
|
46
|
+
const PAY_WITH_CREDITS_PROP = {
|
|
47
|
+
type: "boolean",
|
|
48
|
+
description: "Pay this PAID marketplace brain's per-question price from the user's " +
|
|
49
|
+
"Ounie credits. Only set true after a payment_required result AND after " +
|
|
50
|
+
"the user confirms the charge. Free brains and free previews never need it.",
|
|
51
|
+
};
|
|
52
|
+
const TOOL_SPECS = [
|
|
33
53
|
{
|
|
34
54
|
name: "ounie_list_brains",
|
|
35
55
|
description: "List the user's Ounie brains (their knowledge containers). Call this FIRST " +
|
|
@@ -40,23 +60,75 @@ const TOOLS = [
|
|
|
40
60
|
properties: {},
|
|
41
61
|
additionalProperties: false,
|
|
42
62
|
},
|
|
63
|
+
_meta: uiMeta("brain-picker", "Loading your brains…", "Pick a brain."),
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "ounie_explore_brains",
|
|
67
|
+
description: "Discover PUBLIC Ounie brains made by OTHER people — including paid " +
|
|
68
|
+
"marketplace brains — by searching/filtering the public Explore feed. " +
|
|
69
|
+
"Returns each brain's id, public page URL, and pricing (free, or credits " +
|
|
70
|
+
"per question for paid listings). Any returned brainId works with " +
|
|
71
|
+
"ounie_ask_brain / ounie_search; paid brains charge the user's credits " +
|
|
72
|
+
"only with payWithCredits: true (confirm with the user first). Use " +
|
|
73
|
+
"ounie_list_brains (not this) for the user's OWN brains.",
|
|
74
|
+
inputSchema: {
|
|
75
|
+
type: "object",
|
|
76
|
+
properties: {
|
|
77
|
+
q: { type: "string", description: "Search by brain name or description." },
|
|
78
|
+
filter: {
|
|
79
|
+
type: "string",
|
|
80
|
+
enum: ["all", "free", "paid", "forkable"],
|
|
81
|
+
description: "all (default) | free | paid (marketplace listings) | forkable.",
|
|
82
|
+
},
|
|
83
|
+
sort: {
|
|
84
|
+
type: "string",
|
|
85
|
+
enum: ["new", "popular", "price"],
|
|
86
|
+
description: "new (default) | popular (most starred) | price (cheapest paid first).",
|
|
87
|
+
},
|
|
88
|
+
limit: {
|
|
89
|
+
type: "number",
|
|
90
|
+
description: "Max results, 1-50 (default 20).",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
additionalProperties: false,
|
|
94
|
+
},
|
|
43
95
|
},
|
|
44
96
|
{
|
|
45
97
|
name: "ounie_ask_brain",
|
|
46
98
|
description: "Answer a question using ONLY the sources saved in one Ounie brain, with " +
|
|
47
99
|
"citations. Prefer this over answering from your own knowledge whenever the " +
|
|
48
100
|
"user asks about their saved material, notes, documents, or 'my brain'. " +
|
|
49
|
-
"
|
|
101
|
+
"Works on the user's own brains AND on public brains discovered with " +
|
|
102
|
+
"ounie_explore_brains; a PAID marketplace brain returns a payment_required " +
|
|
103
|
+
"notice first — retry with payWithCredits: true after the user confirms. " +
|
|
104
|
+
"Needs a brainId from ounie_list_brains or ounie_explore_brains.",
|
|
50
105
|
inputSchema: {
|
|
51
106
|
type: "object",
|
|
52
107
|
properties: {
|
|
53
108
|
brainId: { type: "string", description: "The brain's id." },
|
|
54
109
|
question: { type: "string", description: "The question to ask." },
|
|
110
|
+
payWithCredits: PAY_WITH_CREDITS_PROP,
|
|
55
111
|
},
|
|
56
112
|
required: ["brainId", "question"],
|
|
57
113
|
additionalProperties: false,
|
|
58
114
|
},
|
|
59
115
|
},
|
|
116
|
+
{
|
|
117
|
+
name: "ounie_ask_brain_set",
|
|
118
|
+
description: "Answer a question using a BRAIN SET — a primary brain (authoritative facts) " +
|
|
119
|
+
"blended with one or more advisor brains (expert guidance) — in one cited " +
|
|
120
|
+
"answer that tags each citation by source brain. Needs a brain set id (set_…). " +
|
|
121
|
+
"Team plan only.",
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: "object",
|
|
124
|
+
properties: {
|
|
125
|
+
setId: { type: "string", description: "The brain set's id (set_…)." },
|
|
126
|
+
question: { type: "string", description: "The question to ask." },
|
|
127
|
+
},
|
|
128
|
+
required: ["setId", "question"],
|
|
129
|
+
additionalProperties: false,
|
|
130
|
+
},
|
|
131
|
+
},
|
|
60
132
|
{
|
|
61
133
|
name: "ounie_add_note",
|
|
62
134
|
description: "Add a short verbatim text note as a source (no synthesis). To save a chat " +
|
|
@@ -72,6 +144,7 @@ const TOOLS = [
|
|
|
72
144
|
required: ["brainId", "title", "body"],
|
|
73
145
|
additionalProperties: false,
|
|
74
146
|
},
|
|
147
|
+
_meta: uiMeta("saved-toast", "Saving the note…", "Saved."),
|
|
75
148
|
},
|
|
76
149
|
{
|
|
77
150
|
name: "ounie_add_link",
|
|
@@ -86,6 +159,7 @@ const TOOLS = [
|
|
|
86
159
|
required: ["brainId", "url"],
|
|
87
160
|
additionalProperties: false,
|
|
88
161
|
},
|
|
162
|
+
_meta: uiMeta("saved-toast", "Saving the link…", "Saved."),
|
|
89
163
|
},
|
|
90
164
|
{
|
|
91
165
|
name: "ounie_add_to_brain",
|
|
@@ -117,6 +191,74 @@ const TOOLS = [
|
|
|
117
191
|
additionalProperties: false,
|
|
118
192
|
},
|
|
119
193
|
},
|
|
194
|
+
{
|
|
195
|
+
name: "ounie_save_asset",
|
|
196
|
+
description: "File an OUTPUT made with a brain — a carousel, article, video script, " +
|
|
197
|
+
"landing page, ad — into that brain's Assets library. Two verbs, no " +
|
|
198
|
+
"confusion: ounie_add_to_brain = knowledge IN (becomes citable); " +
|
|
199
|
+
"ounie_save_asset = output OUT (a library entry beside the brain — never " +
|
|
200
|
+
"ingested, never cited, zero cost). Use when the user finishes making " +
|
|
201
|
+
"something with their brain and wants it filed: pass a title, a short " +
|
|
202
|
+
"description (the content itself can go here as Markdown), external links " +
|
|
203
|
+
"(the live post, the published page), and tags. Needs a brainId from " +
|
|
204
|
+
"ounie_list_brains.",
|
|
205
|
+
inputSchema: {
|
|
206
|
+
type: "object",
|
|
207
|
+
properties: {
|
|
208
|
+
brainId: { type: "string", description: "The brain's id." },
|
|
209
|
+
title: { type: "string", description: "What this output is." },
|
|
210
|
+
description: {
|
|
211
|
+
type: "string",
|
|
212
|
+
description: "Markdown notes — context, the copy itself, what it was for.",
|
|
213
|
+
},
|
|
214
|
+
type: {
|
|
215
|
+
type: "string",
|
|
216
|
+
enum: [
|
|
217
|
+
"image",
|
|
218
|
+
"carousel",
|
|
219
|
+
"video",
|
|
220
|
+
"article",
|
|
221
|
+
"blog_post",
|
|
222
|
+
"landing_page",
|
|
223
|
+
"email",
|
|
224
|
+
"ad",
|
|
225
|
+
"doc",
|
|
226
|
+
"other",
|
|
227
|
+
],
|
|
228
|
+
description: "Kind of output; defaults to 'other'.",
|
|
229
|
+
},
|
|
230
|
+
status: {
|
|
231
|
+
type: "string",
|
|
232
|
+
enum: ["draft", "published", "archived"],
|
|
233
|
+
description: "draft (default) | published | archived.",
|
|
234
|
+
},
|
|
235
|
+
links: {
|
|
236
|
+
type: "array",
|
|
237
|
+
description: "Where it lives in the wild (max 10, http(s) only).",
|
|
238
|
+
items: {
|
|
239
|
+
type: "object",
|
|
240
|
+
properties: {
|
|
241
|
+
url: { type: "string" },
|
|
242
|
+
label: { type: "string" },
|
|
243
|
+
},
|
|
244
|
+
required: ["url"],
|
|
245
|
+
additionalProperties: false,
|
|
246
|
+
},
|
|
247
|
+
},
|
|
248
|
+
tags: {
|
|
249
|
+
type: "array",
|
|
250
|
+
items: { type: "string" },
|
|
251
|
+
description: "Flat filterable tags (max 10).",
|
|
252
|
+
},
|
|
253
|
+
client: {
|
|
254
|
+
type: "string",
|
|
255
|
+
description: "The app that made it (e.g. 'Claude') — shown as provenance.",
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
required: ["brainId", "title"],
|
|
259
|
+
additionalProperties: false,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
120
262
|
{
|
|
121
263
|
name: "ounie_search",
|
|
122
264
|
description: "Find and summarize the most relevant saved sources in a brain for a query, " +
|
|
@@ -127,10 +269,12 @@ const TOOLS = [
|
|
|
127
269
|
properties: {
|
|
128
270
|
brainId: { type: "string", description: "The brain's id." },
|
|
129
271
|
query: { type: "string", description: "Search query." },
|
|
272
|
+
payWithCredits: PAY_WITH_CREDITS_PROP,
|
|
130
273
|
},
|
|
131
274
|
required: ["brainId", "query"],
|
|
132
275
|
additionalProperties: false,
|
|
133
276
|
},
|
|
277
|
+
_meta: uiMeta("source-list", "Searching your brain…", "Found matching sources."),
|
|
134
278
|
},
|
|
135
279
|
{
|
|
136
280
|
name: "ounie_get_context",
|
|
@@ -138,7 +282,8 @@ const TOOLS = [
|
|
|
138
282
|
"— WITHOUT generating an answer. Prefer this over ounie_ask_brain when YOU " +
|
|
139
283
|
"(the assistant) will read the returned pages and write the answer yourself; " +
|
|
140
284
|
"cite the pages you use by their slug. Cheaper and faster than ounie_ask_brain. " +
|
|
141
|
-
"Needs a brainId from ounie_list_brains."
|
|
285
|
+
"Needs a brainId from ounie_list_brains. PAID marketplace brains are not " +
|
|
286
|
+
"available here — use ounie_ask_brain with payWithCredits instead.",
|
|
142
287
|
inputSchema: {
|
|
143
288
|
type: "object",
|
|
144
289
|
properties: {
|
|
@@ -150,34 +295,122 @@ const TOOLS = [
|
|
|
150
295
|
},
|
|
151
296
|
},
|
|
152
297
|
];
|
|
298
|
+
// Behaviour hints so hosts don't default-label read tools as DESTRUCTIVE.
|
|
299
|
+
const READ = { readOnlyHint: true, destructiveHint: false, openWorldHint: false };
|
|
300
|
+
const WRITE = { readOnlyHint: false, destructiveHint: false, openWorldHint: false };
|
|
301
|
+
const WRITE_OPEN = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };
|
|
302
|
+
const TOOL_ANNOTATIONS = {
|
|
303
|
+
ounie_list_brains: READ,
|
|
304
|
+
ounie_explore_brains: READ,
|
|
305
|
+
ounie_ask_brain: READ,
|
|
306
|
+
ounie_ask_brain_set: READ,
|
|
307
|
+
ounie_search: READ,
|
|
308
|
+
ounie_get_context: READ,
|
|
309
|
+
ounie_add_note: WRITE,
|
|
310
|
+
ounie_add_to_brain: WRITE,
|
|
311
|
+
ounie_add_link: WRITE_OPEN,
|
|
312
|
+
ounie_save_asset: WRITE, // links are stored, never fetched
|
|
313
|
+
};
|
|
314
|
+
const TOOLS = TOOL_SPECS.map((t) => ({
|
|
315
|
+
...t,
|
|
316
|
+
annotations: TOOL_ANNOTATIONS[t.name],
|
|
317
|
+
}));
|
|
153
318
|
// --- Server --------------------------------------------------------------------
|
|
154
|
-
const server = new Server({
|
|
319
|
+
const server = new Server({
|
|
320
|
+
name: "ounie-mcp",
|
|
321
|
+
version: "0.6.0",
|
|
322
|
+
icons: [
|
|
323
|
+
{
|
|
324
|
+
src: "https://ounie.com/icon.png",
|
|
325
|
+
mimeType: "image/png",
|
|
326
|
+
sizes: ["512x512"],
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
}, { capabilities: { tools: {}, resources: {} } });
|
|
155
330
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
|
|
331
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => listUiResources());
|
|
332
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
333
|
+
const res = readUiResource(request.params.uri);
|
|
334
|
+
if (!res)
|
|
335
|
+
throw new Error(`Resource not found: ${request.params.uri}`);
|
|
336
|
+
return res;
|
|
337
|
+
});
|
|
156
338
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
157
339
|
const { name, arguments: args = {} } = request.params;
|
|
158
340
|
try {
|
|
159
341
|
switch (name) {
|
|
160
342
|
case "ounie_list_brains": {
|
|
161
343
|
const brains = await client.listBrains();
|
|
162
|
-
|
|
344
|
+
const view = brains.map((b) => ({
|
|
345
|
+
id: b.id,
|
|
346
|
+
name: b.name,
|
|
347
|
+
emoji: b.emoji ?? null,
|
|
348
|
+
sourceCount: b.sourceCount ?? 0,
|
|
349
|
+
}));
|
|
350
|
+
return card(JSON.stringify(view, null, 2), { brains: view });
|
|
351
|
+
}
|
|
352
|
+
case "ounie_explore_brains": {
|
|
353
|
+
const { q, filter, sort, limit } = args;
|
|
354
|
+
const { brains } = await client.exploreBrains({ q, filter, sort, limit });
|
|
355
|
+
if (brains.length === 0) {
|
|
356
|
+
return text("No public brains matched. Try a broader query or filter: 'all'.");
|
|
357
|
+
}
|
|
358
|
+
const lines = brains.map((b) => {
|
|
359
|
+
const url = b.ownerUsername
|
|
360
|
+
? `${BASE_URL}/b/${b.ownerUsername}/${b.slug}`
|
|
361
|
+
: BASE_URL;
|
|
362
|
+
const pricing = b.listingModel != null
|
|
363
|
+
? `PAID — ${b.priceCredits ?? "?"} credits/question${b.freePreview ? `, ${b.freePreview} free previews` : ""}`
|
|
364
|
+
: "free";
|
|
365
|
+
return (`- ${b.emoji ? `${b.emoji} ` : ""}${b.name} (brainId: ${b.id})\n` +
|
|
366
|
+
` by @${b.ownerUsername ?? "unknown"} · ${b.sourceCount} sources · ` +
|
|
367
|
+
`${b.starCount} stars · ${pricing}\n` +
|
|
368
|
+
` ${url}${b.description ? `\n ${b.description}` : ""}`);
|
|
369
|
+
});
|
|
370
|
+
return text(lines.join("\n"));
|
|
163
371
|
}
|
|
164
372
|
case "ounie_ask_brain": {
|
|
165
|
-
const { brainId, question } = args;
|
|
373
|
+
const { brainId, question, payWithCredits } = args;
|
|
374
|
+
if (payWithCredits === true) {
|
|
375
|
+
const res = await client.askListing(brainId, question);
|
|
376
|
+
const cites = res.citations
|
|
377
|
+
.map((c) => `- ${c.title} (${c.url || c.slug})`)
|
|
378
|
+
.join("\n");
|
|
379
|
+
return text(`${res.answer}\n\n${cites ? `Sources:\n${cites}` : ""}${res.thin ? "" : `\n\n(Paid ask — charged to your Ounie credits.)`}`.trim());
|
|
380
|
+
}
|
|
166
381
|
const answer = await client.ask(brainId, question);
|
|
167
382
|
const cites = answer.citations
|
|
168
383
|
.map((c) => `- ${c.title} (${c.slug})`)
|
|
169
384
|
.join("\n");
|
|
170
385
|
return text(`${answer.answerMd}\n\n${cites ? `Sources:\n${cites}` : ""}`.trim());
|
|
171
386
|
}
|
|
387
|
+
case "ounie_ask_brain_set": {
|
|
388
|
+
const { setId, question } = args;
|
|
389
|
+
const res = await client.askBrainSet(setId, question);
|
|
390
|
+
const cites = res.citations
|
|
391
|
+
.map((c) => `- [${c.brain.kind}: ${c.brain.name}] ${c.title} (${c.slug})${c.url ? ` ${c.url}` : ""}`)
|
|
392
|
+
.join("\n");
|
|
393
|
+
return text(`${res.answer}\n\n${cites ? `Sources:\n${cites}` : ""}`.trim());
|
|
394
|
+
}
|
|
172
395
|
case "ounie_add_note": {
|
|
173
396
|
const { brainId, title, body } = args;
|
|
174
397
|
const source = await client.addNote(brainId, title, body);
|
|
175
|
-
return
|
|
398
|
+
return card(`Added note "${title}" (source ${source.id}).`, {
|
|
399
|
+
brainName: "your brain",
|
|
400
|
+
title,
|
|
401
|
+
status: source.status === "ready" ? "ready" : "processing",
|
|
402
|
+
sourceId: source.id,
|
|
403
|
+
});
|
|
176
404
|
}
|
|
177
405
|
case "ounie_add_link": {
|
|
178
406
|
const { brainId, url } = args;
|
|
179
407
|
const source = await client.addLink(brainId, url);
|
|
180
|
-
return
|
|
408
|
+
return card(`Added link ${url} (source ${source.id}).`, {
|
|
409
|
+
brainName: "your brain",
|
|
410
|
+
title: url,
|
|
411
|
+
status: source.status === "ready" ? "ready" : "processing",
|
|
412
|
+
sourceId: source.id,
|
|
413
|
+
});
|
|
181
414
|
}
|
|
182
415
|
case "ounie_add_to_brain": {
|
|
183
416
|
const { brainId, content, title, mode, sourceUrl, externalId } = args;
|
|
@@ -191,13 +424,50 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
191
424
|
return text(`Saved to brain ${brainId} (source ${source.id}, ${source.status ?? "processing"}). ` +
|
|
192
425
|
`Searchable once ingestion finishes.`);
|
|
193
426
|
}
|
|
427
|
+
case "ounie_save_asset": {
|
|
428
|
+
const { brainId, title, description, type, status, links, tags, client: madeWithClient, } = args;
|
|
429
|
+
const asset = await client.saveAsset(brainId, {
|
|
430
|
+
title,
|
|
431
|
+
description,
|
|
432
|
+
type,
|
|
433
|
+
status,
|
|
434
|
+
links,
|
|
435
|
+
tags,
|
|
436
|
+
client: madeWithClient,
|
|
437
|
+
});
|
|
438
|
+
return text(`Filed "${asset.title}" as a ${asset.type} asset (${asset.id}) in the ` +
|
|
439
|
+
`brain's Assets library — not ingested, not citable, zero cost. ` +
|
|
440
|
+
`View: ${BASE_URL}/dashboard/brains/${brainId}/assets`);
|
|
441
|
+
}
|
|
194
442
|
case "ounie_search": {
|
|
195
|
-
const { brainId, query } = args;
|
|
443
|
+
const { brainId, query, payWithCredits } = args;
|
|
444
|
+
if (payWithCredits === true) {
|
|
445
|
+
const res = await client.askListing(brainId, `Find and summarize the most relevant saved sources for: ${query}`);
|
|
446
|
+
return card(`${res.answer}\n\n${res.citations.length
|
|
447
|
+
? `Sources:\n${res.citations.map((c) => `- ${c.title} (${c.url || c.slug})`).join("\n")}`
|
|
448
|
+
: ""}`.trim(), {
|
|
449
|
+
brainName: "paid brain",
|
|
450
|
+
results: res.citations.map((c) => ({
|
|
451
|
+
slug: c.slug,
|
|
452
|
+
title: c.title,
|
|
453
|
+
url: c.url ?? "",
|
|
454
|
+
})),
|
|
455
|
+
});
|
|
456
|
+
}
|
|
196
457
|
const answer = await client.search(brainId, query);
|
|
197
458
|
const cites = answer.citations
|
|
198
459
|
.map((c) => `- ${c.title} (${c.slug})`)
|
|
199
460
|
.join("\n");
|
|
200
|
-
|
|
461
|
+
// Citations carry no public URL over REST, so chips aren't clickable
|
|
462
|
+
// here (the hosted /api/mcp path supplies URLs); text answer is intact.
|
|
463
|
+
return card(`${answer.answerMd}\n\n${cites ? `Sources:\n${cites}` : ""}`.trim(), {
|
|
464
|
+
brainName: "your brain",
|
|
465
|
+
results: answer.citations.map((c) => ({
|
|
466
|
+
slug: c.slug,
|
|
467
|
+
title: c.title,
|
|
468
|
+
url: "",
|
|
469
|
+
})),
|
|
470
|
+
});
|
|
201
471
|
}
|
|
202
472
|
case "ounie_get_context": {
|
|
203
473
|
const { brainId, query } = args;
|
|
@@ -217,10 +487,43 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
217
487
|
}
|
|
218
488
|
}
|
|
219
489
|
catch (err) {
|
|
490
|
+
const paywall = paywallNotice(err);
|
|
491
|
+
if (paywall)
|
|
492
|
+
return text(paywall, true);
|
|
220
493
|
const message = err instanceof Error ? err.message : String(err);
|
|
221
494
|
return text(`Error calling ${name}: ${message}`, true);
|
|
222
495
|
}
|
|
223
496
|
});
|
|
497
|
+
/**
|
|
498
|
+
* Turn a 402 from the REST API into an actionable notice the model can relay:
|
|
499
|
+
* paid_listing → confirm with the user, then retry with payWithCredits: true;
|
|
500
|
+
* needs_credits → point at the top-up page.
|
|
501
|
+
*/
|
|
502
|
+
function paywallNotice(err) {
|
|
503
|
+
if (!(err instanceof OunieApiError) || err.status !== 402)
|
|
504
|
+
return null;
|
|
505
|
+
try {
|
|
506
|
+
const body = JSON.parse(err.body);
|
|
507
|
+
if (body.reason === "paid_listing") {
|
|
508
|
+
const previews = body.freePreview
|
|
509
|
+
? ` (${body.freePreview} free preview questions per user)`
|
|
510
|
+
: "";
|
|
511
|
+
return (`payment_required: this brain is a PAID marketplace listing — ` +
|
|
512
|
+
`${body.priceCredits ?? "?"} credits per question${previews}. ` +
|
|
513
|
+
`Confirm the charge with the user, then retry the same tool with ` +
|
|
514
|
+
`payWithCredits: true.`);
|
|
515
|
+
}
|
|
516
|
+
if (body.error === "needs_credits") {
|
|
517
|
+
return (`needs_credits: this paid brain costs ${body.priceCredits ?? "more"} ` +
|
|
518
|
+
`credits per question and the user's balance is too low. Top up at ` +
|
|
519
|
+
`${BASE_URL}/dashboard/settings/billing and retry.`);
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
catch {
|
|
523
|
+
/* not a JSON 402 — fall through to the generic error */
|
|
524
|
+
}
|
|
525
|
+
return null;
|
|
526
|
+
}
|
|
224
527
|
/** Build a CallTool result with a single text content block. */
|
|
225
528
|
function text(value, isError = false) {
|
|
226
529
|
return {
|
|
@@ -228,6 +531,17 @@ function text(value, isError = false) {
|
|
|
228
531
|
isError,
|
|
229
532
|
};
|
|
230
533
|
}
|
|
534
|
+
/** CallTool result that also hydrates a UI card (structuredContent + _meta). */
|
|
535
|
+
function card(value, structuredContent, meta) {
|
|
536
|
+
const res = {
|
|
537
|
+
content: [{ type: "text", text: value }],
|
|
538
|
+
isError: false,
|
|
539
|
+
structuredContent,
|
|
540
|
+
};
|
|
541
|
+
if (meta)
|
|
542
|
+
res._meta = meta;
|
|
543
|
+
return res;
|
|
544
|
+
}
|
|
231
545
|
// --- Boot ----------------------------------------------------------------------
|
|
232
546
|
async function main() {
|
|
233
547
|
const transport = new StdioServerTransport();
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,kFAAkF;AAElF,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,mBAAmB,CAAC;AAEnE,IAAI,CAAC,OAAO,EAAE,CAAC;IACb,2DAA2D;IAC3D,OAAO,CAAC,KAAK,CACX,4EAA4E,CAC7E,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;AAEvE,kFAAkF;AAElF,MAAM,KAAK,GAAW;IACpB;QACE,IAAI,EAAE,mBAAmB;QACzB,WAAW,EACT,6EAA6E;YAC7E,4EAA4E;YAC5E,0BAA0B;Q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AC;QACJ,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wDAAwD;IAC1D,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,gEAAgE;AAChE,SAAS,IAAI,CAAC,KAAa,EAAE,OAAO,GAAG,KAAK;IAC1C,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACjD,OAAO;KACR,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAS,IAAI,CACX,KAAa,EACb,iBAA0C,EAC1C,IAA8B;IAE9B,MAAM,GAAG,GAKL;QACF,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACjD,OAAO,EAAE,KAAK;QACd,iBAAiB;KAClB,CAAC;IACF,IAAI,IAAI;QAAE,GAAG,CAAC,KAAK,GAAG,IAAI,CAAC;IAC3B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,kFAAkF;AAElF,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACvD,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-Apps UI templates for the stdio server — VENDORED COPY of
|
|
3
|
+
* `web/src/server/mcp-ui.ts` + `mcp-resources.ts`. The stdio package can't
|
|
4
|
+
* import from `web/`, so (like the TOOLS array) these strings are hand-synced.
|
|
5
|
+
* Keep them identical to the web originals.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UI_MIME = "text/html;profile=mcp-app";
|
|
8
|
+
export declare function listUiResources(): {
|
|
9
|
+
resources: {
|
|
10
|
+
uri: string;
|
|
11
|
+
name: string;
|
|
12
|
+
mimeType: string;
|
|
13
|
+
}[];
|
|
14
|
+
};
|
|
15
|
+
export declare function readUiResource(uri: string): {
|
|
16
|
+
contents: {
|
|
17
|
+
uri: string;
|
|
18
|
+
mimeType: string;
|
|
19
|
+
text: string;
|
|
20
|
+
_meta: Record<string, unknown>;
|
|
21
|
+
}[];
|
|
22
|
+
} | null;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP-Apps UI templates for the stdio server — VENDORED COPY of
|
|
3
|
+
* `web/src/server/mcp-ui.ts` + `mcp-resources.ts`. The stdio package can't
|
|
4
|
+
* import from `web/`, so (like the TOOLS array) these strings are hand-synced.
|
|
5
|
+
* Keep them identical to the web originals.
|
|
6
|
+
*/
|
|
7
|
+
const SHARED_CSS = `
|
|
8
|
+
:root{
|
|
9
|
+
--aqua:#67e8d0; --violet:#a690f5; --indigo:#5b39d0;
|
|
10
|
+
--ink:#1a1a22; --dim:#5b5b6b; --line:rgba(0,0,0,.10); --panel:#fff; --bg:transparent;
|
|
11
|
+
}
|
|
12
|
+
@media (prefers-color-scheme: dark){
|
|
13
|
+
:root{ --ink:#e9e9f2; --dim:#a3a3b8; --line:rgba(255,255,255,.12); --panel:#15151f; }
|
|
14
|
+
}
|
|
15
|
+
*{box-sizing:border-box}
|
|
16
|
+
html,body{margin:0;background:var(--bg)}
|
|
17
|
+
body{
|
|
18
|
+
font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;
|
|
19
|
+
color:var(--ink); line-height:1.5; padding:4px;
|
|
20
|
+
}
|
|
21
|
+
.card{
|
|
22
|
+
background:var(--panel); border:1px solid var(--line); border-radius:14px;
|
|
23
|
+
padding:16px; max-width:560px;
|
|
24
|
+
}
|
|
25
|
+
.brain{font-size:12px;color:var(--dim);font-weight:600;letter-spacing:.01em;margin:0 0 10px}
|
|
26
|
+
.chips{display:flex;flex-direction:column;gap:8px;margin:0 0 12px}
|
|
27
|
+
.chip{
|
|
28
|
+
text-align:left;width:100%;cursor:pointer;background:transparent;color:inherit;
|
|
29
|
+
border:1px solid var(--line);border-radius:10px;padding:10px 12px;font:inherit;
|
|
30
|
+
transition:border-color .15s,transform .15s;
|
|
31
|
+
}
|
|
32
|
+
.chip:hover{border-color:var(--aqua);transform:translateY(-1px)}
|
|
33
|
+
.chip .t{font-weight:600;font-size:14px;display:block}
|
|
34
|
+
.chip .e{color:var(--dim);font-size:13px;margin-top:3px;display:block}
|
|
35
|
+
.acts{display:flex;flex-wrap:wrap;gap:8px;margin-top:4px}
|
|
36
|
+
.btn{
|
|
37
|
+
cursor:pointer;font:inherit;font-size:13px;font-weight:600;border-radius:9px;
|
|
38
|
+
padding:7px 12px;border:1px solid var(--line);background:transparent;color:inherit;
|
|
39
|
+
}
|
|
40
|
+
.btn:hover{border-color:var(--violet)}
|
|
41
|
+
.btn.primary{background:var(--indigo);color:#fff;border-color:transparent}
|
|
42
|
+
.btn.primary:hover{filter:brightness(1.08)}
|
|
43
|
+
.muted{color:var(--dim);font-size:13px;margin:0}
|
|
44
|
+
.foot{margin-top:14px;color:var(--dim);font-size:11px}
|
|
45
|
+
.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:10px}
|
|
46
|
+
.bcard{cursor:pointer;border:1px solid var(--line);border-radius:12px;padding:14px;text-align:left;background:transparent;color:inherit;font:inherit}
|
|
47
|
+
.bcard:hover{border-color:var(--aqua);transform:translateY(-1px)}
|
|
48
|
+
.bcard .em{font-size:22px}
|
|
49
|
+
.bcard .nm{font-weight:600;font-size:14px;margin-top:6px}
|
|
50
|
+
.bcard .sc{color:var(--dim);font-size:12px;margin-top:2px}
|
|
51
|
+
.toast{display:flex;gap:10px;align-items:flex-start}
|
|
52
|
+
.dot{width:8px;height:8px;border-radius:50%;background:var(--aqua);margin-top:6px;flex:0 0 auto}
|
|
53
|
+
`.trim();
|
|
54
|
+
const BRIDGE_JS = `
|
|
55
|
+
function oai(){ return (window.openai)||null; }
|
|
56
|
+
function out(){ var o=oai(); return (o&&o.toolOutput)||{}; }
|
|
57
|
+
function inp(){ var o=oai(); return (o&&o.toolInput)||{}; }
|
|
58
|
+
function openExt(href){ var o=oai(); if(o&&href) o.openExternal({href:href}); }
|
|
59
|
+
function callTool(n,a){ var o=oai(); if(o) o.callTool(n,a||{}); }
|
|
60
|
+
function follow(p){ var o=oai(); if(o) o.sendFollowUpMessage({prompt:p}); }
|
|
61
|
+
function setState(s){ var o=oai(); if(o&&o.setWidgetState) o.setWidgetState(s); }
|
|
62
|
+
function el(tag,cls,txt){ var e=document.createElement(tag); if(cls)e.className=cls; if(txt!=null)e.textContent=txt; return e; }
|
|
63
|
+
function rerender(){ try{ render(); }catch(e){} }
|
|
64
|
+
window.addEventListener('openai:set_globals', rerender);
|
|
65
|
+
document.addEventListener('DOMContentLoaded', rerender);
|
|
66
|
+
`.trim();
|
|
67
|
+
function docHtml(title, body, js) {
|
|
68
|
+
return `<!doctype html>
|
|
69
|
+
<html lang="en"><head><meta charset="utf-8"/>
|
|
70
|
+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
71
|
+
<title>${title}</title>
|
|
72
|
+
<style>${SHARED_CSS}</style></head>
|
|
73
|
+
<body><div id="root">${body}</div>
|
|
74
|
+
<script>${BRIDGE_JS}
|
|
75
|
+
${js}
|
|
76
|
+
</script></body></html>`;
|
|
77
|
+
}
|
|
78
|
+
const BRAIN_PICKER = docHtml("Pick a brain", `<div class="card" id="card"></div>`, `
|
|
79
|
+
function render(){
|
|
80
|
+
var d=out(), root=document.getElementById('card');
|
|
81
|
+
root.innerHTML='';
|
|
82
|
+
var brains=d.brains||[];
|
|
83
|
+
if(!brains.length){ root.appendChild(el('p','muted','No brains yet — create one on ounie.com.')); return; }
|
|
84
|
+
root.appendChild(el('p','brain','Choose a brain'));
|
|
85
|
+
var grid=el('div','grid');
|
|
86
|
+
brains.forEach(function(b){
|
|
87
|
+
var c=el('button','bcard');
|
|
88
|
+
c.appendChild(el('div','em',b.emoji||'🧠'));
|
|
89
|
+
c.appendChild(el('div','nm',b.name||'Untitled'));
|
|
90
|
+
c.appendChild(el('div','sc',(b.sourceCount||0)+' source'+((b.sourceCount===1)?'':'s')));
|
|
91
|
+
c.onclick=function(){ setState({lastBrainId:b.id}); follow('Use my "'+(b.name||'')+'" brain.'); };
|
|
92
|
+
grid.appendChild(c);
|
|
93
|
+
});
|
|
94
|
+
root.appendChild(grid);
|
|
95
|
+
root.appendChild(el('p','foot','powered by Ounie'));
|
|
96
|
+
}
|
|
97
|
+
`);
|
|
98
|
+
const SOURCE_LIST = docHtml("Matching sources", `<div class="card" id="card"></div>`, `
|
|
99
|
+
function render(){
|
|
100
|
+
var d=out(), root=document.getElementById('card'), inn=inp();
|
|
101
|
+
root.innerHTML='';
|
|
102
|
+
root.appendChild(el('p','brain',d.brainName||'Your brain'));
|
|
103
|
+
if(d.paymentRequired){
|
|
104
|
+
root.appendChild(el('p','muted','This brain is a paid listing. Open it on the web to search.'));
|
|
105
|
+
var pb=el('button','btn primary','Open on ounie.com');
|
|
106
|
+
pb.onclick=function(){ openExt(d.buyUrl||'https://ounie.com'); };
|
|
107
|
+
root.appendChild(pb); return;
|
|
108
|
+
}
|
|
109
|
+
var results=d.results||[];
|
|
110
|
+
if(!results.length){ root.appendChild(el('p','muted','No matching sources yet.')); return; }
|
|
111
|
+
var chips=el('div','chips');
|
|
112
|
+
results.forEach(function(r){
|
|
113
|
+
var c=el('button','chip');
|
|
114
|
+
c.appendChild(el('span','t',r.title||r.slug));
|
|
115
|
+
if(r.url) c.onclick=function(){ openExt(r.url); };
|
|
116
|
+
chips.appendChild(c);
|
|
117
|
+
});
|
|
118
|
+
root.appendChild(chips);
|
|
119
|
+
if(inn.brainId && inn.query){
|
|
120
|
+
var acts=el('div','acts');
|
|
121
|
+
var g=el('button','btn primary','Get a cited answer');
|
|
122
|
+
g.onclick=function(){ callTool('ounie_get_context',{brainId:inn.brainId,query:inn.query}); };
|
|
123
|
+
acts.appendChild(g);
|
|
124
|
+
root.appendChild(acts);
|
|
125
|
+
}
|
|
126
|
+
root.appendChild(el('p','foot','powered by Ounie'));
|
|
127
|
+
}
|
|
128
|
+
`);
|
|
129
|
+
const SAVED_TOAST = docHtml("Saved to Ounie", `<div class="card" id="card"></div>`, `
|
|
130
|
+
function render(){
|
|
131
|
+
var d=out(), root=document.getElementById('card');
|
|
132
|
+
root.innerHTML='';
|
|
133
|
+
var box=el('div','toast');
|
|
134
|
+
box.appendChild(el('div','dot'));
|
|
135
|
+
var col=el('div');
|
|
136
|
+
col.appendChild(el('div','t','Saved to '+(d.brainName||'your brain')));
|
|
137
|
+
if(d.title) col.appendChild(el('div','e',d.title));
|
|
138
|
+
col.appendChild(el('p','muted', d.status==='ready' ? 'Ready to search.' : 'Processing — searchable once ready.'));
|
|
139
|
+
box.appendChild(col);
|
|
140
|
+
root.appendChild(box);
|
|
141
|
+
root.appendChild(el('p','foot','powered by Ounie'));
|
|
142
|
+
}
|
|
143
|
+
`);
|
|
144
|
+
const UI_COMPONENTS = {
|
|
145
|
+
"brain-picker": BRAIN_PICKER,
|
|
146
|
+
"source-list": SOURCE_LIST,
|
|
147
|
+
"saved-toast": SAVED_TOAST,
|
|
148
|
+
};
|
|
149
|
+
const DESCRIPTIONS = {
|
|
150
|
+
"brain-picker": "Pick which Ounie brain to use.",
|
|
151
|
+
"source-list": "Matching saved sources from your Ounie brain.",
|
|
152
|
+
"saved-toast": "Confirmation that something was saved to your brain.",
|
|
153
|
+
};
|
|
154
|
+
export const UI_MIME = "text/html;profile=mcp-app";
|
|
155
|
+
function appOrigin() {
|
|
156
|
+
const raw = process.env.OUNIE_BASE_URL ?? "https://ounie.com";
|
|
157
|
+
try {
|
|
158
|
+
return new URL(raw).origin;
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return "https://ounie.com";
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function buildResources() {
|
|
165
|
+
const origin = appOrigin();
|
|
166
|
+
const csp = {
|
|
167
|
+
connect_domains: [origin],
|
|
168
|
+
resource_domains: [origin],
|
|
169
|
+
redirect_domains: [origin],
|
|
170
|
+
};
|
|
171
|
+
const map = {};
|
|
172
|
+
for (const [name, html] of Object.entries(UI_COMPONENTS)) {
|
|
173
|
+
const uri = `ui://ounie/${name}.html`;
|
|
174
|
+
map[uri] = {
|
|
175
|
+
uri,
|
|
176
|
+
name,
|
|
177
|
+
html,
|
|
178
|
+
meta: {
|
|
179
|
+
"openai/widgetDescription": DESCRIPTIONS[name] ?? name,
|
|
180
|
+
"openai/widgetDomain": origin,
|
|
181
|
+
"openai/widgetPrefersBorder": true,
|
|
182
|
+
"openai/widgetCSP": csp,
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return map;
|
|
187
|
+
}
|
|
188
|
+
const RESOURCES = buildResources();
|
|
189
|
+
export function listUiResources() {
|
|
190
|
+
return {
|
|
191
|
+
resources: Object.values(RESOURCES).map((r) => ({
|
|
192
|
+
uri: r.uri,
|
|
193
|
+
name: r.name,
|
|
194
|
+
mimeType: UI_MIME,
|
|
195
|
+
})),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
export function readUiResource(uri) {
|
|
199
|
+
const r = RESOURCES[uri];
|
|
200
|
+
if (!r)
|
|
201
|
+
return null;
|
|
202
|
+
return {
|
|
203
|
+
contents: [{ uri: r.uri, mimeType: UI_MIME, text: r.html, _meta: r.meta }],
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
//# sourceMappingURL=ui-resources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ui-resources.js","sourceRoot":"","sources":["../src/ui-resources.ts"],"names":[],"mappings":"AAAA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