market_analysis
Analyze healthcare specialty market in a US state. Obtain provider density, competition metrics, and market opportunity data.
Instructions
Healthcare specialty market analysis for a specific state. Returns provider density, competition metrics, and market opportunity data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| state | Yes | 2-letter state code (e.g., "TX", "CA") | |
| specialty | Yes | Medical specialty (e.g., "cardiology", "orthopedics") |
Implementation Reference
- src/tools.js:243-252 (handler)Tool definition for market_analysis: registers the tool with description, price ($0.10), endpoint (/agent/v1/market/analysis), and Zod schema (state + specialty inputs).
{ name: 'market_analysis', description: 'Healthcare specialty market analysis for a specific state. Returns provider density, competition metrics, and market opportunity data.', price: '$0.10', endpoint: '/agent/v1/market/analysis', schema: { state: z.string().describe('2-letter state code (e.g., "TX", "CA")'), specialty: z.string().describe('Medical specialty (e.g., "cardiology", "orthopedics")'), }, }, - src/tools.js:247-252 (schema)Input schema for market_analysis: requires 'state' (2-letter code) and 'specialty' (medical specialty name).
endpoint: '/agent/v1/market/analysis', schema: { state: z.string().describe('2-letter state code (e.g., "TX", "CA")'), specialty: z.string().describe('Medical specialty (e.g., "cardiology", "orthopedics")'), }, }, - src/index.js:20-61 (registration)Generic tool registration loop in createMcpServer(): iterates all MCP_TOOLS (including market_analysis) and registers each with the McpServer via s.tool(). The handler fetches from the tool's endpoint URL with the params as JSON body.
s.tool(tool.name, tool.description, tool.schema, async (params) => { const toolDef = getToolByName(tool.name); if (!toolDef) { return { content: [{ type: 'text', text: `Unknown tool: ${tool.name}` }], isError: true }; } try { const response = await fetch(`${API_BASE_URL}${toolDef.endpoint}`, { method: 'POST', headers: { 'Content-Type': 'application/json', ...(API_KEY && { 'X-API-Key': API_KEY }), 'X-Agent-ID': 'mcp-client', 'User-Agent': '@mymedi-ai/mcp-server/1.2.1', }, body: JSON.stringify(params), }); if (response.status === 402) { const paymentInfo = await response.json(); return { content: [{ type: 'text', text: JSON.stringify({ error: 'payment_required', message: `This tool costs ${toolDef.price} per call. Register at ${API_BASE_URL}/bot-marketplace/register for an API key with 10 free starter credits, or pay per call with on-chain USDC (no signup) via the x402 protocol.`, price: toolDef.price, register: `${API_BASE_URL}/bot-marketplace/register`, ...paymentInfo, }, null, 2) }], isError: true, }; } if (!response.ok) { const error = await response.json().catch(() => ({ message: response.statusText })); return { content: [{ type: 'text', text: JSON.stringify({ error: true, status: response.status, ...error }, null, 2) }], isError: true }; } const data = await response.json(); const creditsSpent = response.headers.get('X-Credits-Spent'); const creditsRemaining = response.headers.get('X-Credits-Remaining'); if (creditsSpent) { data._billing = { creditsSpent: parseInt(creditsSpent, 10), creditsRemaining: creditsRemaining ? parseInt(creditsRemaining, 10) : undefined, priceUSD: toolDef.price }; } return { content: [{ type: 'text', text: JSON.stringify(data, null, 2) }] }; } catch (err) { return { content: [{ type: 'text', text: JSON.stringify({ error: true, message: err.message, hint: 'Ensure MCP_API_BASE_URL and MCP_API_KEY environment variables are set.' }, null, 2) }], isError: true }; } }); } - src/index.js:69-71 (registration)Sandbox registration in createSandboxServer(): also registers market_analysis but returns a static 'sandbox' response instead of calling the live API.
sandboxServer.tool(tool.name, tool.description, tool.schema, async () => ({ content: [{ type: 'text', text: 'sandbox' }] })); }