research
Answer questions and solve complex problems by searching the web with AI-powered research capabilities, providing results with citations and references.
Instructions
Ask questions, search for information, or consult about complex problems in English.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes |
Implementation Reference
- main.py:35-68 (handler)The handler function for the 'research' tool. It uses an OpenAI client to perform a web search via the responses.create API with the web_search tool, processes the response, extracts citations from annotations, and formats the output with sources.@mcp.tool def research(query: str) -> str: """ Ask questions, search for information, or consult about complex problems in English. """ # Responses API で Web Search を実行 response = client.responses.create( model="gpt-5.1", tools=[ { "type": "web_search", "search_context_size": "medium", # low/medium/high } ], input=query, ) # レスポンステキストを取得 result_text = response.output_text # 引用情報を抽出してフォーマット citations = [] for item in response.output: if hasattr(item, 'type') and item.type == "message": for content in item.content: if hasattr(content, 'annotations'): for annotation in content.annotations: citations.append(f"- [{annotation.title}]({annotation.url})") # 結果と引用を結合 if citations: result_text += "\n\n## Sources\n" + "\n".join(citations) return result_text