# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-07-07T16:44:08+00:00
import argparse
import json
import os
from typing import *
from autogen.mcp.mcp_proxy import MCPProxy
from autogen.mcp.mcp_proxy.security import APIKeyHeader, BaseSecurity, HTTPBearer
from models import (
AnswerPostRequest,
AnswerResult,
ContentsPostRequest,
ContentsPostResponse,
FindSimilarPostRequest,
FindSimilarPostResponse,
SearchPostRequest,
SearchPostResponse,
)
app = MCPProxy(
description='A comprehensive API for internet-scale search, allowing users to perform queries and retrieve results from a wide variety of sources using embeddings-based and traditional search.',
title='Exa Search API',
version='1.1.4',
servers=[{'url': 'https://api.exa.ai'}],
)
@app.post(
'/answer',
description=""" Performs a search based on the query and generates either a direct answer or a detailed summary with citations, depending on the query type.
""",
tags=['search_functionality', 'content_retrieval'],
)
def answer(body: AnswerPostRequest):
"""
Generate an answer from search results
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post('/contents', tags=['content_retrieval'])
def get_contents(body: ContentsPostRequest):
"""
Get Contents
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/findSimilar',
description=""" Find similar links to the link provided. Optionally get contents. """,
tags=['search_functionality', 'content_retrieval'],
)
def find_similar(body: FindSimilarPostRequest):
"""
Find similar links
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/search',
description=""" Perform a search with a Exa prompt-engineered query and retrieve a list of relevant results. Optionally get contents. """,
tags=['search_functionality', 'content_retrieval'],
)
def search(body: SearchPostRequest):
"""
Search
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="MCP Server")
parser.add_argument(
"transport",
choices=["stdio", "sse", "streamable-http"],
help="Transport mode (stdio, sse or streamable-http)",
)
args = parser.parse_args()
if "CONFIG_PATH" in os.environ:
config_path = os.environ["CONFIG_PATH"]
app.load_configuration(config_path)
if "CONFIG" in os.environ:
config = os.environ["CONFIG"]
app.load_configuration_from_string(config)
if "SECURITY" in os.environ:
security_params = BaseSecurity.parse_security_parameters_from_env(
os.environ,
)
app.set_security_params(security_params)
mcp_settings = json.loads(os.environ.get("MCP_SETTINGS", "{}"))
app.get_mcp(**mcp_settings).run(transport=args.transport)