Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
// list-tools.mjs: print every tool @three-ws/agentcore-payments-mcp advertises,
// with its input schema and its MCP annotation hints.
//
// Spawns this package's own server over stdio the way the README runs it
// (`node src/index.js`), performs the MCP initialize handshake, calls
// tools/list, and prints each tool.
//
// node examples/list-tools.mjs
//
// No credentials and no network: registration is env-free, so the server
// advertises all five tools with no THREE_WS_SESSION or PAYMENT_SESSION_TOKEN
// set. Nothing here can spend money.
//
// Read the hints column. `pay_with_session` is the only non-read-only tool that
// moves funds, and it is the one an MCP client should surface a confirmation for.
import { fileURLToPath } from 'node:url';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import {
StdioClientTransport,
getDefaultEnvironment,
} from '@modelcontextprotocol/sdk/client/stdio.js';
// The README's "Run standalone" entry point. Swap for
// { command: 'npx', args: ['-y', '@three-ws/agentcore-payments-mcp'] } to
// exercise the published package instead of this checkout.
const SERVER_PATH = fileURLToPath(new URL('../src/index.js', import.meta.url));
// Env this server reads (see src/config.js). getDefaultEnvironment() drops
// everything else, so an example never leaks unrelated secrets to the child.
const FORWARDED_ENV = [
'THREE_WS_BASE',
'THREE_WS_TIMEOUT_MS',
'THREE_WS_SESSION',
'PAYMENT_SESSION_TOKEN',
];
function childEnv() {
const env = getDefaultEnvironment();
for (const key of FORWARDED_ENV) {
const value = process.env[key];
if (value) env[key] = value;
}
return env;
}
/**
* One-line summary of a tool's MCP annotation hints.
*
* A tool whose four hints are all `false` is a deliberate declaration (a
* non-destructive, non-idempotent, closed-world write), not a missing one, so
* it must not read the same as a tool that was never annotated. An MCP client
* decides whether to prompt the user off exactly this distinction.
*/
function hints(annotations) {
if (!annotations) return 'UNANNOTATED (client must assume the worst)';
const flags = [];
if (annotations.readOnlyHint) flags.push('read-only');
if (annotations.destructiveHint) flags.push('destructive');
if (annotations.idempotentHint) flags.push('idempotent');
if (annotations.openWorldHint) flags.push('open-world');
if (flags.length) return flags.join(', ');
return 'write, non-destructive, non-idempotent, closed-world';
}
/** Render a JSON Schema property as one readable constraint string. */
function constraints(prop) {
const parts = [prop.type ?? 'any'];
if (Array.isArray(prop.enum)) parts.push(`one of ${prop.enum.join(' | ')}`);
if (prop.default !== undefined) parts.push(`default ${JSON.stringify(prop.default)}`);
if (prop.minimum !== undefined) parts.push(`min ${prop.minimum}`);
if (prop.maximum !== undefined) parts.push(`max ${prop.maximum}`);
if (prop.minLength !== undefined) parts.push(`minLength ${prop.minLength}`);
if (prop.maxLength !== undefined) parts.push(`maxLength ${prop.maxLength}`);
return parts.join(', ');
}
function printTool(tool, index) {
const schema = tool.inputSchema ?? {};
const properties = schema.properties ?? {};
const required = new Set(schema.required ?? []);
const names = Object.keys(properties);
console.log(`\n${index}. ${tool.name}`);
if (tool.title) console.log(` title: ${tool.title}`);
console.log(` hints: ${hints(tool.annotations)}`);
if (tool.description) console.log(` ${tool.description}`);
if (names.length === 0) {
console.log(' params: none');
return;
}
console.log(' params:');
for (const name of names) {
const prop = properties[name];
const flag = required.has(name) ? 'required' : 'optional';
console.log(` - ${name} (${flag}; ${constraints(prop)})`);
if (prop.description) console.log(` ${prop.description}`);
}
}
const transport = new StdioClientTransport({
command: process.execPath,
args: [SERVER_PATH],
env: childEnv(),
stderr: 'inherit',
});
const client = new Client({
name: 'agentcore-payments-mcp-list-tools-example',
version: '1.0.0',
});
await client.connect(transport);
const server = client.getServerVersion();
console.log(`server: ${server?.name} v${server?.version} (stdio)`);
console.log(`capabilities: ${Object.keys(client.getServerCapabilities() ?? {}).join(', ') || 'none'}`);
const { tools } = await client.listTools();
console.log(`tools: ${tools.length}`);
tools.forEach((tool, i) => printTool(tool, i + 1));
const spending = tools.filter((t) => t.annotations && t.annotations.readOnlyHint !== true);
console.log(`\nTools that change state: ${spending.map((t) => t.name).join(', ') || 'none'}`);
console.log('Only pay_with_session moves funds, and only up to the session budget you set.');
await client.close();