buyInPassMarket
Buy tokens for a specific proposal in the pass market using your public key on the Futarchy MCP Server. Facilitates participation in governance and decision-making processes.
Instructions
Buy tokens in the pass market for a proposal
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| amount | Yes | Amount to buy | |
| proposalId | Yes | The ID of the proposal to trade in | |
| user | Yes | User's public key |
Implementation Reference
- src/mcp/server/index.ts:336-370 (handler)MCP tool handler that proxies the buyInPassMarket call to the FutarchyApiClient and formats the responseasync ({ proposalId, amount, user }) => { try { const response = await apiClient.buyInPassMarket(proposalId, amount, user); if (!response.success) { return { content: [ { type: "text" as const, text: response.error || 'Unknown error', }, ], isError: true, }; } return { content: [ { type: "text" as const, text: JSON.stringify(response.data, null, 2), }, ], }; } catch (error: any) { return { content: [ { type: "text" as const, text: `Error buying in pass market: ${error.message || 'Unknown error'}`, }, ], isError: true, }; }
- src/mcp/server/index.ts:332-335 (schema)Zod input schema for the buyInPassMarket tool parametersproposalId: z.string().describe("The ID of the proposal to trade in"), amount: z.number().describe("Amount to buy"), user: z.string().describe("User's public key"), },
- src/mcp/server/index.ts:328-329 (registration)Registration of the buyInPassMarket tool in the MCP serverserver.tool( "buyInPassMarket",
- src/mcp/common/api.ts:164-192 (helper)FutarchyApiClient method that makes HTTP POST request to the backend /proposals/{proposalId}/buy-pass endpointasync buyInPassMarket(proposalId: string, amount: number, userPublicKey: string): Promise<Response> { try { const response = await fetch(`${this.baseUrl}/proposals/${proposalId}/buy-pass`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ amount, user: userPublicKey }) }); if (!response.ok) { throw new Error(`HTTP error! Status: ${response.status}`); } const data = await response.json(); return { success: true, data: data }; } catch (error: any) { return { success: false, error: error.message || 'Failed to buy in pass market' }; } }