-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathcatalog.js
More file actions
95 lines (88 loc) · 3.54 KB
/
Copy pathcatalog.js
File metadata and controls
95 lines (88 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import Ajv from 'ajv';
import addFormats from 'ajv-formats';
import { buildGettingStartedTool } from '../_lib/mcp-getting-started.js';
import { priceFor } from '../_lib/pump-pricing.js';
import { toolDefs as avatarDefs } from './tools/avatars.js';
import { toolDefs as modelDefs } from './tools/models.js';
import { toolDefs as solanaDefs } from './tools/solana.js';
import { toolDefs as pumpfunDefs } from './tools/pumpfun.js';
import { toolDefs as agentDefs } from './tools/agents.js';
import { toolDefs as animationDefs } from './tools/animations.js';
import { toolDefs as memoryDefs } from './tools/memory.js';
import { toolDefs as embedDefs } from './tools/embed.js';
import { toolDefs as oracleDefs } from './tools/oracle.js';
import { toolDefs as traderDefs } from './tools/trader.js';
import { toolDefs as tokenizeDefs } from './tools/tokenize.js';
import { toolDefs as cryptoDataDefs } from './tools/crypto-data.js';
const baseDefs = [
...avatarDefs,
...embedDefs,
...modelDefs,
...animationDefs,
...solanaDefs,
...pumpfunDefs,
...agentDefs,
...memoryDefs,
...oracleDefs,
...traderDefs,
...tokenizeDefs,
...cryptoDataDefs,
];
// Free, public entry point — listed first so discovery clients see it up top.
// priceFor annotates the per-call price of the paid tools in the overview.
// Annotations: a static, local overview built at module load — read-only,
// deterministic, closed-world (destructiveHint is explicit because the MCP
// spec defaults it to true when omitted).
const gettingStarted = {
...buildGettingStartedTool({
server: 'three.ws',
tagline:
'The main three.ws MCP server: render and manage 3D avatars and models, animations, an agent registry, agent memory, live pump.fun market data, Oracle conviction signals, and the trader leaderboard + copy-trading system.',
tools: baseDefs,
priceFor,
access: [
'Connect with a three.ws account (OAuth) for your account-scoped avatars, agents, and memory.',
'Or pay per call via x402 (USDC) for the public tools — each priced tool shows its price in tools/list.',
],
links: { homepage: 'https://three.ws', source: 'https://github.com/nirholas/three.ws' },
}),
annotations: {
readOnlyHint: true,
destructiveHint: false,
idempotentHint: true,
openWorldHint: false,
},
};
const allDefs = [gettingStarted, ...baseDefs];
// Schema objects for tools/list — strip internal fields (scope, handler).
export const TOOL_CATALOG = allDefs.map(({ scope: _s, handler: _h, ...schema }) => schema);
// Compile each tool's inputSchema once per process so dispatch can validate
// args before invoking the handler. The handlers currently trust their args
// and pass them to DB / external APIs; dispatch-level validation is
// defense-in-depth that fails fast on malformed input with a clear MCP
// JSON-RPC error instead of bubbling up a Postgres parse error or worse.
//
// `useDefaults: true` lets the per-tool `default` in JSON Schema (e.g.
// limit defaults) fill in for clients that omit optional fields, matching
// the existing handler behavior (`args.limit || 25`).
//
// `coerceTypes: true` accepts string forms of integers ("25") which some
// older MCP clients emit — same forgiveness the handlers currently rely on.
const ajv = new Ajv({
allErrors: true,
useDefaults: true,
coerceTypes: true,
strict: false,
});
addFormats(ajv);
// Handler lookup for tools/call — keyed by tool name.
export const TOOLS = Object.fromEntries(
allDefs.map(({ name, scope, handler, inputSchema }) => [
name,
{
scope,
handler,
validate: inputSchema ? ajv.compile(inputSchema) : null,
},
]),
);