ベルグハインイベントAPIとMCP実装
プロジェクト構造
要件
Python 3.10以上
uv (依存関係管理と仮想環境用)
AWS アカウント (DynamoDB および App Runner 用)
Firecrawl APIキー
施設
このリポジトリをクローンします:
git clone <repository-url> cd berghain-apiuv
を使用して仮想環境を作成し、アクティブ化します。uv venv source .venv/bin/activate # En Linux/macOS # .venv\\Scripts\\activate # En Windowsuv
を使用して依存関係をインストールします。uv pip install -r requirements.txt
詳細なプロセス
1. Firecrawlによるデータ抽出
Firecrawl MCP をカーソルに設定します。Firecrawl API キーがあることを確認します。カーソル MCP 構成で、以下を追加します。
"firecrawl-mcp": { "command": "npx", "args": [ "-y", "firecrawl-mcp" ], "env": { "FIRECRAWL_API_KEY": "fc-YOUR_FIRECRAWL_API_KEY" } }抽出を実行します。Cursorのエージェント (または同様のツール) を使用して、Firecrawl MCP を呼び出し、
https://www.berghain.berlin/en/program/
からイベントを抽出するように要求します。**データを保存する:**抽出されたデータは、
events/
ディレクトリに JSON ファイルとして保存する必要があります。たとえば、events/berghain_events_YYYY-MM-DD.json
。
2. DynamoDBへのデータのロード
DynamoDB にテーブルを作成します。scripts
scripts/create_table.py
スクリプトがこれを処理します。実行します(必要に応じてパラメータを調整します)。uv run python scripts/create_table.py --table berghain_events --region tu-region-aws # Para desarrollo local con DynamoDB Local (ej. docker run -p 8000:8000 amazon/dynamodb-local): # uv run python scripts/create_table.py --table berghain_events --region localhost --endpoint-url http://localhost:8000テーブルにデータをロードします。scripts
scripts/load_data.py
スクリプトは、JSON ファイルからイベントをロードします。uv run python scripts/load_data.py --table berghain_events --region tu-region-aws --path events # Para desarrollo local: # uv run python scripts/load_data.py --table berghain_events --region localhost --endpoint-url http://localhost:8000 --path events引数として渡さない場合は
app/core/config.py
(load_data.py
によってインポート) に必要な構成があることを確認してください。
3. FastAPIとMCPサーバーを使用したAPI
API ロジックは
app/
ディレクトリにあり、エンドポイントが定義されています (例:app/api/endpoints/events.py
)。app/main.py
ファイルは、FastAPI アプリケーションと FastMCP サーバーを起動するように構成され、API エンドポイントを AI モデルのツールとして公開します。app/main.py
のcustom_maps
をチェックして、 GET ルートがRouteType.TOOL
にどのようにマップされるかを確認します。
AWS へのデプロイメント
に。 Dockerfile
uv
を使用し、 app/main.py
を実行するようにDockerfile
が正しく構成されていることを確認します。
b.イメージをビルドして Amazon ECR (Elastic Container Registry) にアップロードする
ECR を使用して Docker を認証します。
aws ecr get-login-password --region tu-region-aws | docker login --username AWS --password-stdin tu-aws-account-id.dkr.ecr.tu-region-aws.amazonaws.comECR にリポジトリを作成します (存在しない場合)。
aws ecr create-repository --repository-name berghain-mcp-api --region tu-region-awsDocker イメージをビルドします。
docker build -t berghain-mcp-api .画像にタグを付けます:
docker tag berghain-mcp-api:latest tu-aws-account-id.dkr.ecr.tu-region-aws.amazonaws.com/berghain-mcp-api:latest画像を ECR にアップロードします。
docker push tu-aws-account-id.dkr.ecr.tu-region-aws.amazonaws.com/berghain-mcp-api:latesttu-region-aws
とtu-aws-account-id
実際の値に置き換えます。
紀元前Terraform でインフラストラクチャをデプロイする
Terraform ファイルを準備します。Terraform構成ファイル (例:
main.tf
、variables.tf
、outputs.tf
) がディレクトリ (例:terraform/
) にあることを確認します。これらのファイルでは、ECR イメージが使用する AWS App Runner サービスや DynamoDB テーブル (Terraform でも管理されている場合) などの必要な AWS リソースを定義する必要があります。 Terraform の App Runner 構成では、ECR にアップロードされたイメージを参照する必要があります。Terraform ディレクトリに移動します。
cd terraformTerraform を初期化します。
terraform initTerraform 構成を適用します。
terraform apply計画を確認し、申請を確定します。 Terraform がリソースをプロビジョニングします。
**サービス URL を取得します。**適用すると、Terraform によって、App Runner サービス URL を含む定義済みの出力が表示されます。この URL (例:
https://<id-servicio>.<region>.awsapprunner.com
) をメモします。
展開したソリューションをテストする
に。ローカルテストスクリプトを調整する ( mcp_local.py
)
mcp_local.py
ファイルをプロジェクトのルートに設定します。
重要: mcp_local.py
のmcp_server_url
変数を、Terraform ��力から取得した URL に更新します。
b.テストを実行
プロジェクトのルート (またはmcp_local.py
保存した場所) から:
これにより、PydanticAI エージェントが実行され、デプロイされた MCP に接続してクエリを実行しようとします。
ライセンス
マサチューセッツ工科大学
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
DynamoDB を利用した FastAPI サービスを通じて、AI エージェントが Berghain ナイトクラブの今後のイベントに関する情報を照会および取得できるようにするサーバー。
Related MCP Servers
- AsecurityFlicenseAqualityThis server integrates with the Ticketmaster API to provide AI agents with real-time concert and event data, enabling dynamic fetching and formatting for ease of interpretation.Last updated -12
- AsecurityAlicenseAqualityThis server provides tools for AI assistants to interact with the Eventbrite API, allowing users to search for events, get event details, retrieve venue information, and list event categories.
- -securityAlicense-qualityIntegrates with the Eventbrite API to provide AI-assisted event management capabilities for viewing events, tracking attendees, and generating analytics reports.Last updated -01MIT License
- -securityAlicense-qualityA powerful server that enables AI agents to interact with MySQL databases, execute SQL queries, and manage database content through a simple interface.Last updated -4396MIT License