dmc-mcp-server
This server is an MCP tool that lets you query Tencent Cloud TDSQL-C/TDSQL databases through the DMC web API using your browser login session.
Set or update the Tencent Cloud console cookie and mc_gtk for authenticated API access
Find database instances by internal IP across both TDSQL-C and TDSQL types
Log in to database instances with cached sessions to avoid repeated logins
Execute SELECT queries (only SELECT allowed) with configurable page size
List databases and tables, including fuzzy table search
View table structure details and CREATE TABLE DDL
List currently active logged-in database sessions
Supports multiple Tencent Cloud regions
Handles token expiry by auto re-login using cached credentials
Executes SELECT queries on Tencent Cloud TDSQL-C and TDSQL MySQL databases via DMC web API, with tools for instance discovery, login, and schema browsing.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@dmc-mcp-server list databases on the TDSQL-C instance with IP 10.0.0.5"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
dmc-mcp-server
通过腾讯云 DMC (Data Management Console) 在 TDSQL-C / TDSQL 数据库实例上执行 SQL 查询的 MCP Server。
原理
浏览器 (腾讯云控制台登录态)
│ Cookie (skey/uin) + mc_gtk (csrfCode)
▼
DMC MCP Server
│ ① 按实例类型搜索 API:
│ TDSQL-C → cynosdb.cloud.tencent.com DescribeClusters (本地过滤 Vip)
│ TDSQL → tdsql.cloud.tencent.com DescribeDCDBInstances (服务端 SearchKey)
│ ② RSA 加密 DB 密码 (PKCS#1 v1.5)
│ ③ POST dms.cloud.tencent.com/api/mysql/dbLogin → token
│ ④ POST dms.cloud.tencent.com/api/mysql/schemaAdmin/commonSql → 查询结果
▼
TDSQL-C / TDSQL MySQL (内网 IP)利用腾讯云 DMC 控制台的 Web API,通过浏览器 Cookie 复用登录态,实现从本地对生产内网数据库的 SQL 查询。
Related MCP server: SQL Server MCP Server
安装
方式一:uvx 一键运行(推荐)
uvx dmc-mcp-server方式二:从源码安装
cd dmc-mcp-server
uv sync
uv run dmc-mcp-server配置
在 MCP 客户端中添加
在你的 MCP 客户端配置中添加 (如 opencode.jsonc, claude_desktop_config.json):
{
"mcpServers": {
"dmc-mcp-server": {
"command": "uvx",
"args": ["dmc-mcp-server"]
}
}
}Cookie 不写在配置中, 启动后通过
set_cookie工具动态设置.
Cookie 获取方式
启动 MCP 后, 通过 Chrome DevTools MCP 在腾讯云控制台页面自动获取:
// Cookie
document.cookie
// mc_gtk (csrfCode) - 从 performance API 提取
performance.getEntriesByType('resource')
.find(e => e.name.includes('csrfCode='))
?.name.match(/csrfCode=(\d+)/)?.[1]然后调用 set_cookie(cookie, mc_gtk) 工具设置.
也可手动从浏览器 DevTools 复制
document.cookie的值, 但 mc_gtk 必须从 performance API 提取.
工具列表
工具 | 说明 |
| 设置/更新腾讯云控制台 Cookie + mc_gtk |
| 通过内网 IP 搜索数据库实例(同时搜 TDSQL-C 和 TDSQL) |
| 登录数据库实例(会话缓存,不重复登录) |
| 执行 SELECT 查询(仅允许 SELECT) |
| 列出实例上的所有数据库 |
| 列出指定库的表(支持模糊搜索) |
| 查看表结构(列信息 + DDL) |
| 查看已登录的实例列表 |
支持的数据库类型
类型 | dbType | 实例ID前缀 | 搜索 API |
TDSQL-C (CynosDB) |
|
|
|
TDSQL (DCDB) |
|
|
|
find_instance_by_ip 会同时搜索两种类型,返回结果中包含 DbType 字段供 login_instance 使用。
地域 (Region)
login_instance 的 region_id 参数和 find_instance_by_ip 的 region 参数用于指定集群所在地域。
默认值: region_id=4 / region="ap-shanghai" (上海)
如果你的集群在其他地域,需要传入对应的值:
地域 | region_id | region (API 参数) |
北京 | 1 |
|
上海 | 4 |
|
广州 | 7 |
|
深圳 | 11 |
|
成都 | 16 |
|
重庆 | 23 |
|
南京 | 45 |
|
香港 | 21 |
|
新加坡 | 15 |
|
硅谷 | 13 |
|
法兰克福 | 17 |
|
完整列表见 腾讯云地域文档
特性
双类型支持:同时支持 TDSQL-C (CynosDB) 和 TDSQL (DCDB) 实例
仅 SELECT:SQL 执行层强制限制只允许 SELECT 语句
会话复用:登录过的实例自动缓存 token,不重复登录
自动重连:token 过期时自动重新登录(使用缓存的凭据)
Cookie 动态更新:运行时通过工具更新,无需重启 Server
代理兼容:自动清除系统代理环境变量,避免 socks5 代理导致连接卡死
约束
Cookie 有效期约 2 小时(腾讯云控制台标准),过期需重新获取
SQL 仅支持 SELECT(WITH...SELECT 也允许)
DB 权限取决于 DB 账号本身的 GRANT 权限
TDSQL 需要数据库账号已对 DMC 服务器 IP 段授权(否则登录报 ACCESS_DENIED)
License
MIT
Link
Available Tools
8 toolsexecute_selectA
Execute a SELECT query on a logged-in database instance. Only SELECT statements are allowed (enforced by SQL validation).
Args: instance_id: Instance ID (must be logged in via login_instance first) sql: SELECT SQL statement to execute db_name: Target database name within the instance page_size: Max rows to return, default 50
Returns: Query results as formatted text.
Inputs: sql (required), db_name (required), instance_id (required), page_size. Returns: result
find_instance_by_ipA
Find a database instance by its internal Vip (proxy IP). Searches both TDSQL-C (CynosDB) and TDSQL (DCDB) instances.
Typical workflow:
Read the JDBC URL from your config file (e.g. 10.0.0.1:3306)
Call find_instance_by_ip("10.0.0.1", region="ap-guangzhou") to get the InstanceId
Call login_instance with the InstanceId (use the DbType from results, and match region_id)
Call execute_select
Args: ip: Internal Vip address, e.g. "10.0.0.1" region: Tencent Cloud region string, e.g. "ap-shanghai" (default), "ap-beijing", "ap-guangzhou". Must match the region where your cluster is deployed.
Returns: Matching instance info (InstanceId, Name, Vip, DbType) or "not found".
Inputs: ip (required), region. Returns: result
get_table_detailA
Get detailed schema of a table: columns and DDL (CREATE TABLE statement).
Args: instance_id: Instance ID (must be logged in) db_name: Database name table_name: Table name
Returns: Column details and CREATE TABLE DDL.
Inputs: db_name (required), table_name (required), instance_id (required). Returns: result
list_active_sessionsA
List all currently active (logged-in) database instance sessions. Useful to check which instances are ready for querying.
Returns: List of active instance IDs and their session status.
Inputs: no named parameters. Returns: result
list_databasesA
List all databases accessible by the current logged-in account on the specified instance.
Args: instance_id: Instance ID (must be logged in)
Returns: List of database names.
Inputs: instance_id (required). Returns: result
list_tablesC
List tables in a database, optionally filtered by name pattern.
Args: instance_id: Instance ID (must be logged in) db_name: Database name search: Optional table name filter (fuzzy match)
Returns: Table list with row counts and sizes.
Inputs: db_name (required), instance_id (required), search. Returns: result
login_instanceA
Login to a database instance via Tencent Cloud DMC. Supports both TDSQL-C (CynosDB) and TDSQL (DCDB) instances. The session is cached - subsequent calls reuse the same token without re-login, unless the token expires.
Use find_instance_by_ip to discover the instance_id and db_type, then pass the db_type value from the search results here.
Args: instance_id: Instance ID, e.g. "cynosdbmysql-xxx" or "tdsqlshard-xxx" user: Database account name, e.g. "db_user" password: Database account password (plain text) db_type: Database type - "cynosdbmysql" (TDSQL-C) or "tdsql" (TDSQL) region_id: Region ID, default 4 (Shanghai)
Returns: Login status message.
Inputs: user (required), password (required), instance_id (required), db_type, +1 more. Returns: result
set_cookieA
Set or update the Tencent Cloud console cookie. AI can obtain this from the browser via Chrome DevTools MCP: document.cookie Then pass the full cookie string here.
The mc_gtk (csrfCode) value is required for cluster search (DescribeClusters API). AI can extract it from the browser's performance API: performance.getEntriesByType('resource') .find(e => e.name.includes('csrfCode=')) ?.name.match(/csrfCode=(\d+)/)?.[1] If not provided, DMC login/SQL tools will still work (they don't require mc_gtk to be valid), but find_instance_by_ip will fail.
Args: cookie: Full cookie string from the Tencent Cloud console browser tab. mc_gtk: Optional csrfCode value from the browser. Required for cluster search.
Inputs: cookie (required), mc_gtk. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: login, query, list databases, list tables, get table details, find instance by IP, list active sessions, and set cookie. There is no overlap or confusion between tools.
All tool names follow a consistent snake_case verb_noun pattern (e.g., execute_select, login_instance, list_databases). No mixing of conventions or ambiguous verbs.
8 tools is well-scoped for a database management server, covering authentication, instance discovery, schema exploration, querying, and session monitoring without being too few or too many.
The tool set covers the core read-only workflow (login, query, schema browsing, instance discovery) well. A minor gap is the absence of a logout or session close tool, but overall the surface is appropriate for the intended use.
Maintenance
Related MCP Connectors
Hosted SQL Server MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
MCP server for querying and analyzing data from ad platforms, analytics tools, and spreadsheets
Hosted MySQL MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Hosted BigQuery MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA FastAPI-based server that enables executing SQL queries, managing database connections, and retrieving analytics reports through MCP-integrated endpoints. It allows users to interact with database schemas, performance metrics, and access logs using structured queries.-
- AlicenseNot gradedqualityDmaintenanceA containerized Model Context Protocol server for SQL Server operations, enabling query execution, table management, and database operations through the MCP protocol.1MIT
- AlicenseNot gradedqualityNot gradedmaintenanceMCP server for connecting to databases (PostgreSQL, MySQL, SQL Server, Redis) enabling SQL queries, table exploration, and Redis key-value operations.1MIT
- FlicenseNot gradedqualityDmaintenanceA multi-database MCP server supporting PostgreSQL, ClickHouse, and MySQL that enables database exploration and SQL execution through MCP stdio or HTTP API.-