MCP Opinion
An MCP server for interacting with Opinion.trade prediction market
- Package:
@iqai/mcp-opinion - Purpose: Interacting with the Opinion.trade prediction market for market data and analysis.
Usage with ADK TypeScript
import {McpOpinion} from "@iqai/adk";
const toolset = McpOpinion({
env: {
OPINION_API_KEY: process.env.OPINION_API_KEY,
},
})
const tools = await toolset.getTools()import {McpToolset} from "@iqai/adk";
const toolset = new McpToolset({
name: "Opinion MCP Client",
description: "Client for Opinion.trade prediction market",
transport: {
mode: "stdio",
command: "pnpm",
args: ["dlx", "@iqai/mcp-opinion"],
env: {
OPINION_API_KEY: process.env.OPINION_API_KEY,
PATH: process.env.PATH || "",
},
},
})
const tools = await toolset.getTools(){
"mcpServers": {
"opinion-mcp-server": {
"command": "pnpm",
"args": ["dlx", "@iqai/mcp-opinion"],
"env": {
"OPINION_API_KEY": "your_opinion_api_key"
}
}
}
}Available Tools
GET_MARKETSlimit:numberstatus:numbermarketType:numberpage:number
GET_MARKETSDescription
Get a list of prediction markets from Opinion.trade with optional filters for status and market type
GET_MARKET_DETAILSmarketId:number
GET_MARKET_DETAILSDescription
Get detailed information about a specific prediction market by its ID
SEARCH_MARKETSquery:stringlimit:numberstatus:number
SEARCH_MARKETSDescription
Search for prediction markets by keyword in the market title
GET_ORDERBOOKtokenId:string
GET_ORDERBOOKDescription
Get the order book (bids and asks) for a specific prediction market token
GET_PRICE_HISTORYtokenId:stringinterval:string
GET_PRICE_HISTORYDescription
Get historical price data for a prediction market token
GET_LATEST_PRICEtokenId:string
GET_LATEST_PRICEDescription
Get the current/latest trade price for a prediction market token
GET_POSITIONSwalletAddress:stringlimit:numberpage:number
GET_POSITIONSDescription
Get the current prediction market positions held by a wallet address
GET_TRADE_HISTORYwalletAddress:stringlimit:numberpage:number
GET_TRADE_HISTORYDescription
Get the trade history for a wallet address on Opinion.trade
GET_QUOTE_TOKENSNo parameters
GET_QUOTE_TOKENSNo parameters
Description
Get the list of available quote tokens (currencies) that can be used for trading on Opinion.trade
Environment Variables
OPINION_API_KEY: Required. Your Opinion.trade API key.
Usage Examples
Here's a complete example of using MCP Opinion with an ADK agent:
import { McpOpinion, AgentBuilder } from "@iqai/adk";
import dotenv from "dotenv";
dotenv.config();
async function main() {
// Initialize Opinion MCP toolset
const toolset = McpOpinion({
env: {
OPINION_API_KEY: process.env.OPINION_API_KEY,
},
debug: false,
retryOptions: {
maxRetries: 3,
initialDelay: 500,
},
});
// Get available tools
const opinionTools = await toolset.getTools();
// Create agent with Opinion tools
const { runner } = await AgentBuilder.create("opinion_agent")
.withModel("gemini-2.5-flash")
.withDescription(
"An agent that interacts with Opinion.trade prediction markets",
)
.withTools(...opinionTools)
.build();
try {
// Example queries
const response = await runner.ask(
"Show me trending markets on Opinion.trade",
);
console.log(response);
} finally {
// Clean up resources
await toolset.close();
}
}
main().catch(console.error);Getting Your Credentials
- Sign up at Opinion.trade
- Navigate to your account settings
- Generate an API key
Best Practices
- Security: Store API keys in environment variables, never hardcode them
- Resource Cleanup: Always call
await toolset.close()when done to properly close connections - Error Handling: Implement proper error handling for market data requests
- Rate Limits: Be aware of API rate limits and implement appropriate retry logic
Error Handling
Error Scenarios
The server handles various error scenarios gracefully.
šØ Missing credentials: Ensure OPINION_API_KEY is set
š Invalid market identifiers: Verify market IDs are correct
š Network issues: Check your internet connection and API status
Resources
- Opinion.trade - Opinion.trade prediction market platform
- Model Context Protocol - MCP specification and standards