@outfitter/mcp 0.4.1 → 0.4.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.
- package/README.md +39 -29
- package/dist/actions.d.ts +3 -3
- package/dist/actions.js +25 -4
- package/dist/core-tools.d.ts +3 -3
- package/dist/core-tools.js +140 -6
- package/dist/index.d.ts +7 -952
- package/dist/index.js +7 -959
- package/dist/logging.d.ts +1 -1
- package/dist/schema.d.ts +1 -1
- package/dist/schema.js +1 -1
- package/dist/server.d.ts +3 -3
- package/dist/server.js +2 -2
- package/dist/shared/@outfitter/{mcp-jk0ka9hw.d.ts → mcp-7kcw2814.d.ts} +4 -4
- package/dist/shared/@outfitter/{mcp-nmp5wf0w.js → mcp-b502y16n.js} +1 -1
- package/dist/shared/@outfitter/{mcp-a0cgfsnw.d.ts → mcp-d8vs6vry.d.ts} +1 -1
- package/dist/shared/@outfitter/{mcp-h2twz77x.d.ts → mcp-gqjg15f5.d.ts} +166 -196
- package/dist/shared/@outfitter/mcp-hw5wz4gb.js +1 -0
- package/dist/shared/@outfitter/{mcp-2vqyt1fj.d.ts → mcp-knq080yt.d.ts} +1 -1
- package/dist/shared/@outfitter/{mcp-dwd800vf.d.ts → mcp-s6afm4ff.d.ts} +14 -14
- package/dist/transport.d.ts +3 -3
- package/dist/transport.js +161 -5
- package/dist/types.d.ts +2 -2
- package/package.json +31 -30
- package/dist/shared/@outfitter/mcp-ktapzh9d.js +0 -28
- package/dist/shared/@outfitter/mcp-mzky3ck8.js +0 -165
- package/dist/shared/@outfitter/mcp-zv3ej45k.js +0 -143
- package/dist/shared/@outfitter/mcp-zy7b487d.js +0 -5
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
// packages/mcp/src/core-tools.ts
|
|
3
|
-
import { Result, ValidationError } from "@outfitter/contracts";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
var DEFAULT_DOCS = {
|
|
6
|
-
overview: "No documentation configured yet.",
|
|
7
|
-
tools: [],
|
|
8
|
-
examples: [],
|
|
9
|
-
schemas: {}
|
|
10
|
-
};
|
|
11
|
-
var docsSchema = z.object({
|
|
12
|
-
section: z.enum(["overview", "tools", "examples", "schemas"]).optional()
|
|
13
|
-
});
|
|
14
|
-
function pickDocsSection(payload, section) {
|
|
15
|
-
if (!section) {
|
|
16
|
-
return payload;
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
[section]: payload[section]
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function defineDocsTool(options = {}) {
|
|
23
|
-
return {
|
|
24
|
-
name: "docs",
|
|
25
|
-
description: options.description ?? "Documentation, usage patterns, and examples for this MCP server.",
|
|
26
|
-
deferLoading: false,
|
|
27
|
-
inputSchema: docsSchema,
|
|
28
|
-
handler: async (input) => {
|
|
29
|
-
const payload = options.getDocs ? await options.getDocs(input.section) : options.docs ?? DEFAULT_DOCS;
|
|
30
|
-
return Result.ok(pickDocsSection(payload, input.section));
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
var configSchema = z.object({
|
|
35
|
-
action: z.enum(["get", "set", "list"]),
|
|
36
|
-
key: z.string().optional(),
|
|
37
|
-
value: z.unknown().optional()
|
|
38
|
-
});
|
|
39
|
-
function createInMemoryStore(initial = {}) {
|
|
40
|
-
const store = new Map(Object.entries(initial));
|
|
41
|
-
return {
|
|
42
|
-
get(key) {
|
|
43
|
-
return { value: store.get(key), found: store.has(key) };
|
|
44
|
-
},
|
|
45
|
-
set(key, value) {
|
|
46
|
-
store.set(key, value);
|
|
47
|
-
},
|
|
48
|
-
list() {
|
|
49
|
-
return Object.fromEntries(store.entries());
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function defineConfigTool(options = {}) {
|
|
54
|
-
const store = options.store ?? createInMemoryStore(options.initial);
|
|
55
|
-
return {
|
|
56
|
-
name: "config",
|
|
57
|
-
description: options.description ?? "Read or modify server configuration values.",
|
|
58
|
-
deferLoading: false,
|
|
59
|
-
inputSchema: configSchema,
|
|
60
|
-
handler: async (input) => {
|
|
61
|
-
switch (input.action) {
|
|
62
|
-
case "list": {
|
|
63
|
-
const config = await store.list();
|
|
64
|
-
return Result.ok({ action: "list", config });
|
|
65
|
-
}
|
|
66
|
-
case "get": {
|
|
67
|
-
if (!input.key) {
|
|
68
|
-
return Result.err(new ValidationError({
|
|
69
|
-
message: "Config key is required for action 'get'.",
|
|
70
|
-
field: "key"
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
const { value, found } = await store.get(input.key);
|
|
74
|
-
return Result.ok({ action: "get", key: input.key, value, found });
|
|
75
|
-
}
|
|
76
|
-
case "set": {
|
|
77
|
-
if (!input.key) {
|
|
78
|
-
return Result.err(new ValidationError({
|
|
79
|
-
message: "Config key is required for action 'set'.",
|
|
80
|
-
field: "key"
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
await store.set(input.key, input.value);
|
|
84
|
-
return Result.ok({
|
|
85
|
-
action: "set",
|
|
86
|
-
key: input.key,
|
|
87
|
-
value: input.value
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
default:
|
|
91
|
-
return Result.err(new ValidationError({
|
|
92
|
-
message: `Unknown action: ${input.action}`,
|
|
93
|
-
field: "action"
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
var querySchema = z.object({
|
|
100
|
-
q: z.string().min(1).describe("Search query. Supports natural language or filter syntax.").optional(),
|
|
101
|
-
query: z.string().min(1).describe("Alias for q. Supports natural language or filter syntax.").optional(),
|
|
102
|
-
limit: z.number().int().positive().optional(),
|
|
103
|
-
cursor: z.string().optional(),
|
|
104
|
-
filters: z.record(z.string(), z.unknown()).optional()
|
|
105
|
-
}).refine((value) => {
|
|
106
|
-
const queryValue = (value.q ?? value.query)?.trim();
|
|
107
|
-
return typeof queryValue === "string" && queryValue.length > 0;
|
|
108
|
-
}, {
|
|
109
|
-
message: "Query is required.",
|
|
110
|
-
path: ["q"]
|
|
111
|
-
});
|
|
112
|
-
function defineQueryTool(options = {}) {
|
|
113
|
-
return {
|
|
114
|
-
name: "query",
|
|
115
|
-
description: options.description ?? "Search and discover resources with filters and pagination.",
|
|
116
|
-
deferLoading: false,
|
|
117
|
-
inputSchema: querySchema,
|
|
118
|
-
handler: (input, ctx) => {
|
|
119
|
-
const normalized = {
|
|
120
|
-
...input,
|
|
121
|
-
q: (input.q ?? input.query ?? "").trim()
|
|
122
|
-
};
|
|
123
|
-
if (options.handler) {
|
|
124
|
-
return options.handler(normalized, ctx);
|
|
125
|
-
}
|
|
126
|
-
return Promise.resolve(Result.ok({
|
|
127
|
-
results: [],
|
|
128
|
-
_meta: {
|
|
129
|
-
note: "No query handler configured."
|
|
130
|
-
}
|
|
131
|
-
}));
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function createCoreTools(options = {}) {
|
|
136
|
-
return [
|
|
137
|
-
defineDocsTool(options.docs),
|
|
138
|
-
defineConfigTool(options.config),
|
|
139
|
-
defineQueryTool(options.query)
|
|
140
|
-
];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export { defineDocsTool, defineConfigTool, defineQueryTool, createCoreTools };
|