Skip to content

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.

feat(mcp): add list_my_agents tool and record MCP client analytics

nirholasbdfdd1ece4af
diff --git a/api/_lib/migrations/20261009172000_mcp_client_analytics.sql b/api/_lib/migrations/20261009172000_mcp_client_analytics.sql
new file mode 100644
index 000000000..d16513384
--- /dev/null
+++ b/api/_lib/migrations/20261009172000_mcp_client_analytics.sql
@@ -0,0 +1,50 @@
+-- Migration: which AI clients use the hosted three.ws MCP servers.
+-- Apply: node scripts/apply-migrations.mjs --apply --file 20261009172000_mcp_client_analytics.sql
+-- Idempotent.
+--
+-- Every MCP `initialize` carries clientInfo.name and version. The servers record
+-- it per session and count tool calls against that session, so the question
+-- "how much of our traffic is Grok Bot versus Claude, ChatGPT or Cursor" has an
+-- answer. No request body, argument, IP or token is ever stored, only a
+-- normalized client name, its version, the auth kind and tool names.
+--
+-- mcp_client_sessions raw rows, one per initialize. Expire after 30 days
+-- (api/cron/db-retention.js).
+-- mcp_client_daily durable aggregate per day, surface, client, version
+-- and auth kind: sessions opened and calls made.
+-- mcp_client_tool_daily durable aggregate of calls per tool for the same day,
+-- surface, client and auth kind.
+
+create table if not exists mcp_client_sessions (
+ session_id text primary key,
+ surface text not null,
+ client_name text not null,
+ client_version text not null default '',
+ auth_kind text not null,
+ calls integer not null default 0,
+ created_at timestamptz not null default now(),
+ last_seen_at timestamptz not null default now()
+);
+
+create index if not exists mcp_client_sessions_last_seen_idx on mcp_client_sessions (last_seen_at);
+
+create table if not exists mcp_client_daily (
+ day date not null,
+ surface text not null,
+ client_name text not null,
+ client_version text not null default '',
+ auth_kind text not null,
+ sessions integer not null default 0,
+ calls integer not null default 0,
+ primary key (day, surface, client_name, client_version, auth_kind)
+);
+
+create table if not exists mcp_client_tool_daily (
+ day date not null,
+ surface text not null,
+ client_name text not null,
+ auth_kind text not null,
+ tool text not null,
+ calls integer not null default 0,
+ primary key (day, surface, client_name, auth_kind, tool)
+);
diff --git a/api/_mcp-studio/account-tools.js b/api/_mcp-studio/account-tools.js
index c1c79be43..6ec37f00d 100644
--- a/api/_mcp-studio/account-tools.js
+++ b/api/_mcp-studio/account-tools.js
@@ -29,6 +29,7 @@ const CORE_SERVER = 'three.ws';
export const GROK_ACCOUNT_TOOLS = Object.freeze([
// Agents
'create_agent',
+ 'list_my_agents',
'attach_avatar_to_agent',
'identity_check',
'call_agent',
diff --git a/api/_mcp/tools/agents.js b/api/_mcp/tools/agents.js
index 9b3f7feff..254c5bd4e 100644
--- a/api/_mcp/tools/agents.js
+++ b/api/_mcp/tools/agents.js
@@ -656,4 +656,50 @@ export const toolDefs = [
return toolResult(structured);
},
},
+ {
+ name: 'list_my_agents',
+ title: 'List my agents',
+ annotations: {
+ readOnlyHint: true,
+ destructiveHint: false,
+ idempotentHint: true,
+ openWorldHint: false,
+ },
+ description:
+ 'List the agents on your account, newest first: id, name, description, brain model, public Solana address, whether the page is published and the page URL. Use the ids with recall, list_custom_skills, attach_avatar_to_agent and call_agent. Reads only; no funds move.',
+ inputSchema: {
+ type: 'object',
+ properties: {
+ limit: { type: 'integer', minimum: 1, maximum: 100, default: 50, description: 'How many agents to return.' },
+ },
+ additionalProperties: false,
+ },
+ scope: 'agents:read',
+ async handler(args, auth) {
+ if (!auth.userId) {
+ return designedError('sign_in_required', 'Sign in with three.ws OAuth or an API key to list your agents.');
+ }
+ const limit = Math.min(Math.max(Number(args?.limit) || 50, 1), 100);
+ const rows = await sql`
+ SELECT id, name, description, is_published, created_at,
+ meta->>'solana_address' AS solana_address,
+ meta->'brain'->>'provider' AS model
+ FROM agent_identities
+ WHERE user_id = ${auth.userId} AND deleted_at IS NULL
+ ORDER BY created_at DESC
+ LIMIT ${limit}
+ `;
+ const agents = rows.map((r) => ({
+ id: r.id,
+ name: r.name,
+ description: r.description || null,
+ model: r.model || null,
+ solana_address: r.solana_address || null,
+ is_published: Boolean(r.is_published),
+ created_at: r.created_at,
+ page_url: agentHomeUrl(r.id),
+ }));
+ return toolResult({ count: agents.length, agents });
+ },
+ },
];
diff --git a/packages/mcp-policy/src/table.js b/packages/mcp-policy/src/table.js
index 9778b33cb..28970da11 100644
--- a/packages/mcp-policy/src/table.js
+++ b/packages/mcp-policy/src/table.js
@@ -89,6 +89,7 @@ export const POLICY = {
identity_check: r('agents'),
list_feedback: r('utility'),
list_garment_catalog: r('assets'),
+ list_my_agents: r('agents'),
list_my_avatars: r('assets'),
list_sign_vocabulary: r('assets'),
mint_3d_asset: w('assets'),