main.py•7.11 kB
# generated by fastapi-codegen:
# filename: openapi.yaml
# timestamp: 2025-07-07T17:24:58+00:00
import argparse
import json
import os
from typing import *
from typing import Optional, Union
from autogen.mcp.mcp_proxy import MCPProxy
from autogen.mcp.mcp_proxy.security import APIKeyHeader, BaseSecurity
from fastapi import UploadFile
from models import (
Context,
CreateContext,
CreateContextResponse,
CreateSession,
Error,
Extension,
Project,
ProjectUsage,
Session,
SessionLiveUrls,
SessionStatus,
SessionUpdate,
Uuid,
V1ProjectsGetResponse,
V1SessionsGetResponse,
V1SessionsIdLogsGetResponse,
V1SessionsIdRecordingGetResponse,
V1SessionsIdUploadsPostResponse,
V1SessionsPostResponse,
)
app = MCPProxy(
description='Browserbase API for 3rd party developers',
title='Browserbase API',
version='v1',
servers=[
{
'description': 'Public endpoint',
'url': 'https://www.browserbase.com',
'variables': {},
}
],
)
@app.post(
'/v1/contexts',
tags=['context_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def contexts_create(body: CreateContext):
"""
Create a Context
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/contexts/{id}',
tags=['context_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def contexts_get(id: Uuid):
"""
Context
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.put(
'/v1/contexts/{id}',
tags=['context_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def contexts_update(id: str):
"""
Update Context
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/v1/extensions',
tags=['extension_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def extensions_upload(file: UploadFile):
"""
Upload an Extension
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.delete(
'/v1/extensions/{id}',
tags=['extension_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def extensions_delete(id: Uuid):
"""
Delete Extension
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/extensions/{id}',
tags=['extension_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def extensions_get(id: Uuid):
"""
Extension
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/projects',
tags=['project_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def projects_list():
"""
List all projects
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/projects/{id}',
tags=['project_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def projects_get(id: Uuid):
"""
Project
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/projects/{id}/usage',
tags=['project_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def projects_usage(id: Uuid):
"""
Project Usage
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_list(status: Optional[SessionStatus] = None):
"""
List Sessions
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/v1/sessions',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_create(body: CreateSession):
"""
Create a Session
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions/{id}',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_get(id: Uuid):
"""
Session
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/v1/sessions/{id}',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_update(id: str, body: SessionUpdate = ...):
"""
Update Session
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions/{id}/debug',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_get_debug(id: Uuid):
"""
Session Live URLs
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions/{id}/downloads',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_get_downloads(id: Uuid):
"""
Session Downloads
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions/{id}/logs',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_get_logs(id: Uuid):
"""
Session Logs
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.get(
'/v1/sessions/{id}/recording',
tags=['session_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_get_recording(id: Uuid):
"""
Session Recording
"""
raise RuntimeError("Should be patched by MCPProxy and never executed")
@app.post(
'/v1/sessions/{id}/uploads',
tags=['session_operations', 'extension_operations'],
security=[
APIKeyHeader(name="X-BB-API-Key"),
],
)
def sessions_upload_file(id: str, file: UploadFile = ...):
"""
Create Session Uploads
"""
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)