frontrun_classify
Classify Twitter users by analyzing their activity with AI and custom rules to identify venture capital signals and trending companies.
Instructions
Run classification on specific entities. Returns AI classification merged with your custom rules and tags. Use this to analyze entities on demand.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| usernames | No | Usernames to classify | |
| twitter_user_ids | No | Twitter user IDs to classify |
Implementation Reference
- index.js:368-374 (handler)The handler function for frontrun_classify tool that takes usernames and/or twitter_user_ids, constructs a request body, and calls the POST /classify API endpoint, returning the result as JSON text.
async ({ usernames, twitter_user_ids }) => { const body = {}; if (usernames) body.usernames = usernames; if (twitter_user_ids) body.twitter_user_ids = twitter_user_ids; const result = await apiCall('POST', '/classify', body); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } - index.js:364-367 (schema)Zod schema defining the input parameters for frontrun_classify: optional arrays of usernames and twitter_user_ids, both as strings.
{ usernames: z.array(z.string()).optional().describe('Usernames to classify'), twitter_user_ids: z.array(z.string()).optional().describe('Twitter user IDs to classify'), }, - index.js:361-375 (registration)Registration of the frontrun_classify tool with the MCP server using server.tool(), including the tool name, description, schema, and handler.
server.tool( 'frontrun_classify', 'Run classification on specific entities. Returns AI classification merged with your custom rules and tags. Use this to analyze entities on demand.', { usernames: z.array(z.string()).optional().describe('Usernames to classify'), twitter_user_ids: z.array(z.string()).optional().describe('Twitter user IDs to classify'), }, async ({ usernames, twitter_user_ids }) => { const body = {}; if (usernames) body.usernames = usernames; if (twitter_user_ids) body.twitter_user_ids = twitter_user_ids; const result = await apiCall('POST', '/classify', body); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } ); - index.js:29-73 (helper)Helper function used by frontrun_classify (and other tools) to make authenticated API calls to the Frontrun API with error handling, timeout, and response parsing.
async function apiCall(method, path, body = null) { const url = `${API_URL}/v1${path}`; const options = { method, headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json', }, }; if (body) { options.body = JSON.stringify(body); } const controller = new AbortController(); const timeout = setTimeout(() => controller.abort(), 60000); options.signal = controller.signal; let response; try { response = await fetch(url, options); } catch (err) { clearTimeout(timeout); if (err.name === 'AbortError') return { error: 'Request timed out (60s). Try a narrower query.' }; return { error: `Network error: ${err.message}` }; } clearTimeout(timeout); if (response.status === 429) { const retry = response.headers.get('Retry-After') || '60'; return { error: `Rate limited. Retry in ${retry}s.` }; } if (response.status === 401) { return { error: 'Invalid API key. Check FRONTRUN_API_KEY.' }; } if (response.status === 402) { const data = await response.json(); return { error: 'Insufficient balance', ...data }; } if (!response.ok) { const text = await response.text(); return { error: `HTTP ${response.status}: ${text.slice(0, 500)}` }; } return response.json(); }