Django Firebase MCP

Django Firebase MCP

A Django app that implements Firebase Model Context Protocol server, enabling AI agents to interact with Firebase services (Authentication, Firestore Database, Cloud Storage) through a standardized protocol.

Category
访问服务器

README

Django Firebase MCP

A comprehensive Django app that implements Firebase Model Context Protocol (MCP) server, enabling AI agents to interact with Firebase services through a standardized protocol.

🚀 Quick Start

Get up and running in under 5 minutes with the standalone Firebase agent for testing.

Prerequisites

  • Python 3.11+
  • Firebase project with Admin SDK
  • Git (optional)

1. Clone & Setup

git clone https://github.com/your-repo/django-firebase-mcp.git
cd django-firebase-mcp

2. Install Dependencies

pip install -r requirements.txt

3. Firebase Setup

Get Firebase Credentials

  1. Go to Firebase Console
  2. Select your project (or create a new one)
  3. Navigate to Project SettingsService Accounts
  4. Click "Generate new private key"
  5. Download the JSON file and save it as credentials.json in the project root

Enable Firebase Services

Make sure these services are enabled in your Firebase project:

  • Authentication (for user management)
  • Firestore Database (for document storage)
  • Cloud Storage (for file uploads)

4. Environment Configuration

Create a .env file in the project root:

# Firebase Configuration
SERVICE_ACCOUNT_KEY_PATH=credentials.json
FIREBASE_STORAGE_BUCKET=your-project-id.appspot.com

# MCP Configuration
MCP_TRANSPORT=http
MCP_HOST=127.0.0.1
MCP_PORT=8001

# Django Settings
DEBUG=True
SECRET_KEY=your-secret-key-here

⚠️ Important: Replace your-project-id with your actual Firebase project ID.

5. Quick Test with Standalone Agent

Test your setup immediately with the standalone Firebase agent:

# Run the standalone agent
python firebase_admin_mcp/standalone_firebase_agent.py

You should see:

🔥 Firebase MCP Agent Ready!
Type 'help' for available commands, 'quit' to exit.

>

Try these commands:

> List all Firebase collections
> Check Firebase health status
> help
> quit

6. Full Django Setup (Optional)

For full Django integration:

# Apply migrations
python manage.py migrate

# Create superuser (optional)
python manage.py createsuperuser

# Run Django development server
python manage.py runserver 8001

The MCP server will be available at: http://127.0.0.1:8001/mcp/

🛠️ Management Commands

Core Commands

# Run standalone Firebase agent (quick testing)
python firebase_admin_mcp/standalone_firebase_agent.py

# Run MCP server via Django
python manage.py runserver 8001

# Run MCP server in stdio mode (for MCP clients)
python manage.py run_mcp --transport stdio

# Run MCP server in HTTP mode
python manage.py run_mcp --transport http --host 127.0.0.1 --port 8001

# Run standalone agent via Django management command
python manage.py run_standalone_agent

Testing Commands

# Test Firebase connectivity
python firebase_admin_mcp/tests/test_firebase_connection.py

# Test MCP server completeness
python firebase_admin_mcp/tests/test_mcp_complete.py

# Demo Firebase agent
python firebase_admin_mcp/tests/demo_firebase_agent.py

# Demo standalone agent
python firebase_admin_mcp/demo_standalone_agent.py

🔧 Available Tools

The MCP server provides 14 Firebase tools across three categories:

🔐 Authentication (4 tools)

  • firebase_verify_token - Verify Firebase ID tokens
  • firebase_create_custom_token - Create custom auth tokens
  • firebase_get_user - Get user info by UID
  • firebase_delete_user - Delete user accounts

📚 Firestore Database (6 tools)

  • firestore_list_collections - List all collections
  • firestore_create_document - Create new documents
  • firestore_get_document - Retrieve documents
  • firestore_update_document - Update documents
  • firestore_delete_document - Delete documents
  • firestore_query_collection - Query with filters

🗄️ Cloud Storage (4 tools)

  • storage_list_files - List files with filtering
  • storage_upload_file - Upload files
  • storage_download_file - Download files
  • storage_delete_file - Delete files

🧪 Quick Testing

Test Server Health

curl http://127.0.0.1:8001/mcp/

Test a Firebase Tool

curl -X POST http://127.0.0.1:8001/mcp/ \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "firestore_list_collections",
      "arguments": {}
    },
    "id": 1
  }'

🤖 AI Agent Integration

LangChain Example

from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# Import Firebase tools
from firebase_admin_mcp.tools.agents.firebase_mcp_client import ALL_FIREBASE_TOOLS

# Create agent with Firebase capabilities
model = ChatOpenAI(model="gpt-4")
agent = create_react_agent(
    model=model,
    tools=ALL_FIREBASE_TOOLS,
    prompt="You are a Firebase assistant with full database and storage access."
)

# Use the agent
response = agent.invoke({
    "messages": [{"role": "user", "content": "Show me all my Firestore collections"}]
})

📚 Documentation

This project includes comprehensive documentation:

  • FIREBASE_ADMIN_MCP.md - Complete technical documentation

    • Detailed API reference
    • All tool specifications
    • Advanced configuration
    • Security considerations
    • Production deployment guide
  • STANDALONE_AGENT.md - Standalone agent documentation

    • Self-contained Firebase agent
    • Complete feature overview
    • Usage examples
    • Integration patterns

🔧 Troubleshooting

Common Issues

Problem: Default app does not exist error Solution: Verify credentials.json path in .env file

Problem: Server won't start Solution: Check if port 8001 is available: netstat -an | findstr :8001

Problem: Firebase connection fails Solution: Verify Firebase services are enabled in console

Problem: Import errors Solution: Ensure all dependencies installed: pip install -r requirements.txt

🎯 What's Next?

  1. Explore the Standalone Agent - Perfect for quick testing and demos
  2. Read the Full Documentation - See FIREBASE_ADMIN_MCP.md for complete details
  3. Integrate with Your AI Agents - Use the MCP tools in your applications
  4. Customize for Your Needs - Extend with additional Firebase operations

📝 Project Structure

django-firebase-mcp/
├── README.md                          # This file
├── FIREBASE_ADMIN_MCP.md             # Complete documentation
├── STANDALONE_AGENT.md               # Standalone agent guide
├── requirements.txt                   # Python dependencies
├── credentials.json                   # Firebase credentials (you create this)
├── .env                              # Environment variables (you create this)
├── manage.py                         # Django management
├── firebase_admin_mcp/               # Main MCP app
│   ├── standalone_firebase_agent.py  # Standalone agent
│   ├── tools/                        # Firebase MCP tools
│   ├── management/commands/          # Django commands
│   └── tests/                        # Test suite
└── django_firebase_mcp/             # Django project settings

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Test your changes
  4. Submit a pull request

📄 License

MIT License - see LICENSE file for details.


🔥 Ready to supercharge your AI agents with Firebase?

Start with the standalone agent, then explore the full documentation for advanced usage!

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选