@useagents/redop 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 UseAgents
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,230 @@
1
+ # redop
2
+
3
+ Bun-native MCP server framework for building typed tools, middleware, hooks, and plugins.
4
+
5
+ ## Why Redop
6
+
7
+ Redop is designed for Bun-first MCP servers that should feel small, typed, and composable.
8
+
9
+ - typed handlers with Zod support
10
+ - HTTP and stdio transports
11
+ - middleware and lifecycle hooks
12
+ - reusable plugin composition
13
+ - Bun-native production deployment shape
14
+
15
+ ## Installation
16
+
17
+ Install the package directly:
18
+
19
+ ```sh
20
+ bun add redop zod
21
+ ```
22
+
23
+ Or scaffold a full app:
24
+
25
+ ```sh
26
+ bun create redop-app
27
+ ```
28
+
29
+ ## Quick start
30
+
31
+ ```ts
32
+ import { Redop } from "redop";
33
+ import { z } from "zod";
34
+
35
+ new Redop({
36
+ name: "my-mcp-server",
37
+ version: "0.1.0",
38
+ })
39
+ .tool("search", {
40
+ description: "Search the web",
41
+ input: z.object({
42
+ query: z.string().min(1),
43
+ }),
44
+ handler: ({ input }) => {
45
+ return {
46
+ query: input.query,
47
+ results: [],
48
+ };
49
+ },
50
+ })
51
+ .listen({
52
+ port: Number(process.env.PORT ?? 3000),
53
+ hostname: "0.0.0.0",
54
+ cors: true,
55
+ onListen: ({ url }) => {
56
+ console.log(`redop ready -> ${url}`);
57
+ },
58
+ });
59
+ ```
60
+
61
+ ## Core concepts
62
+
63
+ ### Tools
64
+
65
+ Use `.tool(...)` to register MCP tools.
66
+
67
+ ```ts
68
+ app.tool("ping", {
69
+ description: "Health check",
70
+ handler: () => ({ ok: true }),
71
+ });
72
+ ```
73
+
74
+ ### Typed input
75
+
76
+ Pass a Zod schema to get typed handler input.
77
+
78
+ ```ts
79
+ app.tool("search", {
80
+ input: z.object({
81
+ query: z.string(),
82
+ limit: z.number().int().min(1).max(50).default(10),
83
+ }),
84
+ handler: ({ input }) => {
85
+ return search(input.query, input.limit);
86
+ },
87
+ });
88
+ ```
89
+
90
+ ### Middleware
91
+
92
+ Middleware wraps tool execution and can read request metadata and mutate `ctx`.
93
+
94
+ ```ts
95
+ import { middleware } from "redop";
96
+
97
+ app.use(
98
+ middleware(async ({ request, ctx, next }) => {
99
+ ctx.startedAt = performance.now();
100
+ console.log(request.transport);
101
+ return next();
102
+ })
103
+ );
104
+ ```
105
+
106
+ ### Hooks
107
+
108
+ Use global hooks for cross-cutting behavior.
109
+
110
+ ```ts
111
+ app
112
+ .onBeforeHandle(({ ctx }) => {
113
+ ctx.startedAt = performance.now();
114
+ })
115
+ .onAfterHandle(({ tool, ctx }) => {
116
+ console.log(tool, performance.now() - ctx.startedAt);
117
+ });
118
+ ```
119
+
120
+ ### Plugins
121
+
122
+ Any `Redop` instance can be reused as a plugin with `.use(...)`.
123
+
124
+ ```ts
125
+ import { analytics, logger, rateLimit } from "redop";
126
+
127
+ app
128
+ .use(logger({ level: "info" }))
129
+ .use(analytics({ sink: "console" }))
130
+ .use(rateLimit({ max: 60, window: "1m" }));
131
+ ```
132
+
133
+ ## Transports
134
+
135
+ ### HTTP
136
+
137
+ Use HTTP for hosted MCP servers:
138
+
139
+ ```ts
140
+ app.listen({
141
+ port: Number(process.env.PORT ?? 3000),
142
+ hostname: "0.0.0.0",
143
+ cors: true,
144
+ });
145
+ ```
146
+
147
+ Auto-mounted routes:
148
+
149
+ - `POST /mcp`
150
+ - `GET /mcp`
151
+ - `DELETE /mcp`
152
+ - `GET /mcp/health`
153
+ - `GET /mcp/schema`
154
+
155
+ ### STDIO
156
+
157
+ Use stdio for local MCP host integrations:
158
+
159
+ ```ts
160
+ app.listen({
161
+ transport: "stdio",
162
+ });
163
+ ```
164
+
165
+ ## Lifecycle
166
+
167
+ Execution order:
168
+
169
+ ```txt
170
+ onTransform -> onBeforeHandle -> tool.before -> middleware -> handler -> tool.after -> onAfterHandle -> mapResponse
171
+ ```
172
+
173
+ ## Schema support
174
+
175
+ Redop works with:
176
+
177
+ - Zod
178
+ - JSON Schema
179
+ - Standard Schema
180
+ - custom adapters
181
+
182
+ Example:
183
+
184
+ ```ts
185
+ app.tool("echo", {
186
+ input: {
187
+ type: "object",
188
+ properties: {
189
+ message: { type: "string" },
190
+ },
191
+ required: ["message"],
192
+ },
193
+ handler: ({ input }) => input.message,
194
+ });
195
+ ```
196
+
197
+ ## Production shape
198
+
199
+ For production, the default Bun HTTP shape is:
200
+
201
+ ```ts
202
+ app.listen({
203
+ port: Number(process.env.PORT ?? 3000),
204
+ hostname: "0.0.0.0",
205
+ cors: true,
206
+ });
207
+ ```
208
+
209
+ Use:
210
+
211
+ - `process.env.PORT`
212
+ - `0.0.0.0`
213
+ - `/mcp/health` for health checks
214
+
215
+ ## Examples
216
+
217
+ See the local examples:
218
+
219
+ - [`basic.ts`](/home/evans/projects/redop-ai/packages/redop/examples/basic.ts)
220
+ - [`with-zod.ts`](/home/evans/projects/redop-ai/packages/redop/examples/with-zod.ts)
221
+ - [`plugins.ts`](/home/evans/projects/redop-ai/packages/redop/examples/plugins.ts)
222
+
223
+ ## Documentation
224
+
225
+ - Docs site: https://redop.useagents.site
226
+ - Docs source: [`apps/docs`](/home/evans/projects/redop-ai/apps/docs)
227
+
228
+ ## License
229
+
230
+ MIT © UseAgents
@@ -0,0 +1,7 @@
1
+ import type { InferSchemaOutput, SchemaAdapter, StandardSchemaV1 } from "../types";
2
+ type JsonSchema = Record<string, unknown>;
3
+ export declare function standardSchemaAdapter<S extends StandardSchemaV1 = StandardSchemaV1>(): SchemaAdapter<S, InferSchemaOutput<S>>;
4
+ export declare function zodAdapter<S extends StandardSchemaV1 = StandardSchemaV1>(): SchemaAdapter<S, InferSchemaOutput<S>>;
5
+ export declare function jsonSchemaAdapter(): SchemaAdapter<JsonSchema, JsonSchema>;
6
+ export declare function detectAdapter(schema: unknown): SchemaAdapter;
7
+ export {};
@@ -0,0 +1,5 @@
1
+ export { detectAdapter, jsonSchemaAdapter, standardSchemaAdapter, zodAdapter, } from "./adapters/schema";
2
+ export { analytics, apiKey, bearer, cache, logger, rateLimit, } from "./plugins/index";
3
+ export { definePlugin, middleware, Redop } from "./redop";
4
+ export type { AfterHook, BeforeHook, Context, CorsOptions, ErrorHook, InferSchemaOutput, ListenOptions, MapResponseHook, PluginDefinition, PluginFactory, PluginMeta, RequestMeta, RedopOptions, ResolvedTool, SchemaAdapter, StandardSchemaIssue, StandardSchemaJsonOptions, StandardSchemaResultFailure, StandardSchemaResultSuccess, StandardSchemaV1, ToolHandler, ToolHandlerEvent, ToolMiddleware, ToolMiddlewareEvent, ToolNext, ToolRequest, ToolDef, ToolAfterHook, ToolAfterHookEvent, ToolBeforeHook, ToolBeforeHookEvent, TransformHook, TransportKind, } from "./types";
5
+ export { McpError, McpErrorCode } from "./types";