Redop is the main class for building MCP servers. Use the constructor for server metadata and top-level behavior, then register tools, resources, prompts, hooks, middleware, and plugins.
Constructor
Constructor options
| Option | Purpose |
|---|---|
serverInfo | Grouped MCP-facing metadata returned during initialize. |
capabilities | Enable or disable advertised MCP capabilities. |
serverInfo fields
| Field | Purpose |
|---|---|
name | Machine-readable server name. Defaults to "redop". |
title | Optional human-readable display name. |
version | Version returned during initialize. Defaults to "0.1.0". |
description | Short server description for supporting client UIs. |
icons | Optional icon metadata from the MCP implementation schema. |
websiteUrl | Optional canonical site or docs URL. |
instructions | Optional usage guidance returned as top-level initialize.instructions. |
Icon shape
icons accepts an array of objects with this shape:
srcis required and should usually be anhttps:URL ordata:URI.mimeTypeis optional, but common values areimage/png,image/jpeg,image/jpg,image/svg+xml, andimage/webp.sizessupports values like["48x48"],["48x48", "96x96"], or["any"]for scalable icons.themecan be"light"or"dark".- Clients should treat icon URLs and bytes as untrusted input and apply normal fetch/render safety checks.
Deprecated top-level fields
Redop still accepts top-levelname, title, version, description, icons, websiteUrl, and instructions, but they are deprecated. Put new docs and new app code under serverInfo.
Main methods
| Method | Purpose |
|---|---|
tool(name, def) | Register an MCP tool. |
resource(uri, def) | Register a static or template resource. |
prompt(name, def) | Register an MCP prompt. |
derive(fn) | Add reusable request context before hooks and handlers run. |
use(plugin) | Merge another Redop instance as a feature module or plugin. |
middleware(fn) | Register global middleware. |
onTransform(fn) | Mutate raw params before schema parsing. |
onParse(fn) | Replace parsed input before before-hooks and middleware. |
onBeforeHandle(fn) | Observe each tool, resource, or prompt request before middleware and handlers. |
onAfterHandle(fn) | Observe successful results after local after hooks and before the response is written. |
onAfterResponse(fn) | Observe tool, resource, and prompt executions after the response is written. |
onError(fn) | Observe thrown errors from middleware or handlers. |
notifyResourceChanged(uri) | Push resources/updated notifications to subscribed clients. |
listen() / listen(3000) / listen(opts) | Start the HTTP or stdio transport. |
Introspection
toolNamesreturns registered tool namesresourceUrisreturns registered resource URIspromptNamesreturns registered prompt namesgetTool(name)returns the resolved tool metadatagetResource(uri)returns the resolved resource metadatagetPrompt(name)returns the resolved prompt metadataserverInforeturns the MCP server identity used during initialize
Composition pattern
Use.use(...) as the main way to compose a larger server.
In practice, that usually means:
- create one
Redopinstance per feature folder - register that feature’s tools, resources, prompts, hooks, or middleware there
- import those modules into the root server
- attach them with
.use(...)