SQLite Database MCP Server with Google OAuth
Enables AI assistants to perform CRUD operations on a SQLite database, with all tools protected by Google OAuth 2.0 authentication.
README
SQLite Database MCP Server with Google OAuth
A simple demonstration MCP (Model Context Protocol) Server in Python that allows an AI assistant to perform CRUD operations on a SQLite database. All MCP tools are protected using Google OAuth 2.0.
Overview
The server manages a single employees table in a SQLite database (company.db). Before executing any CRUD operation, it authenticates the user via the Google OAuth 2.0 Authorization Code flow. The server opens a browser window, completes authentication, and stores the user's email in-memory for the duration of the session.
Folder Structure
.
├── server.py # Main entry point, sets up FastMCP and registers tools
├── auth.py # Google OAuth 2.0 logic and local callback server
├── database.py # SQLAlchemy setup, session management, and sample data injection
├── models.py # SQLAlchemy model definitions
├── tools.py # CRUD operations exposed as MCP tools
├── config.py # Loads environment variables
├── .env # Environment variables (Credentials)
├── requirements.txt # Python dependencies
└── README.md # This documentation
Installing Dependencies
Make sure you have Python 3.12+ installed, then run:
pip install -r requirements.txt
Setting up Google OAuth Credentials
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- Navigate to APIs & Services > Credentials.
- Click Create Credentials > OAuth client ID.
- Select Web application as the application type.
- Under Authorized redirect URIs, add exactly what is in your
.envfile (e.g.,http://localhost:8080/callback). - Click Create and copy your Client ID and Client Secret.
Configuring .env
Edit the .env file and replace the placeholder values with your actual Google OAuth credentials:
GOOGLE_CLIENT_ID=your-client-id-here
GOOGLE_CLIENT_SECRET=your-client-secret-here
REDIRECT_URI=http://localhost:8080/callback
Note: You can change the port in REDIRECT_URI if port 8080 is already in use. The auth.py script automatically parses this URL to determine which port to listen on.
Running the MCP Server
You can run the server in development mode using the FastMCP CLI or via an MCP inspector:
fastmcp dev server.py
Alternatively, configure your AI Assistant (like Claude Desktop) to run the server script directly via stdio.
Authenticating with Google
When the AI Assistant attempts to call an MCP tool for the first time:
- The server will detect that you are not authenticated.
- It will automatically open your default web browser to the Google Sign-In page.
- Once you sign in and grant permission, Google will redirect you to
http://localhost:8080/callback. - A local HTTP server intercepts the authorization code, exchanges it for an access token, and fetches your email.
- The browser will display an "Authentication successful!" message, and the original tool call will proceed.
- The authentication state is kept in memory for the lifecycle of the Python process.
Example MCP Tool Calls
Once authenticated, your AI Assistant can use the following tools:
get_all_employees(): Returns a list of all employees.get_employee_by_id(employee_id=1): Returns the details of a specific employee.add_employee(name="Jane Doe", email="jane@example.com", department="IT", salary=100000): Inserts a new employee.update_employee(employee_id=1, salary=130000): Updates specific fields for an employee.delete_employee(employee_id=3): Deletes an employee from the database.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。