mcp服务器ntopng
](https://pypi.org/project/mcp-ntopng)
NTOPNG模型上下文协议服务器
A. 模型上下文协议 服务器实现 NTOPNG 这使得AI代理能够使用NTOPNG数据库查询网络监控数据。
此MCP服务器假定 ntopng 正在使用ClickHouse存储历史流量和警报。检查 ntopng Clickhouse
工具
fetch_ntopng_all_ifids
- 从ntopng中检索所有可用的接口ID。
get_ntopng_hosts_location
- 获取主机的地理位置和其他信息。
fetch_ntopng_top_local_talkers
- 检索指定接口的前10个本地讲话者。
fetch_ntopng_top_remote_talkers
- 检索指定接口的前10个远程讲话者。
get_ntopng_all_alert_stats
- 检索所有警报的统计信息。
get_ntopng_flow_alert_stats
- 检索流量警报的统计信息。
get_ntopng_host_alert_stats
- 检索主机警报的统计信息。
get_ntopng_interface_alert_stats
- 检索接口警报的统计信息。
get_ntopng_mac_alert_stats
- 检索MAC警报的统计信息。
get_ntopng_network_alert_stats
- 检索网络警报的统计信息。
get_ntopng_snmp_device_alert_list
- 检索SNMP设备警报列表。
get_ntopng_snmp_device_alert_stats
- 检索SNMP设备警报的统计信息。
get_ntopng_system_alert_stats
- 检索系统警报的统计信息。
query_ntopng_flows_data
- 从ntopng流数据库中检索详细的流数据。
get_ntopng_top-k_flows
- 从ntopng流数据库中检索top-k流数据。
get_ntopng_user_alert_stats
- 检索用户警报的统计信息。
get_ntopng_flow_devices_stats
- 检索所有流量设备的统计数据。
get_ntopng_sflow_devices_stats
- 检索所有sFlow设备的统计信息。
list_tables_ntopng_database
- 列出ntopng数据库的表结构。
query_ntopng_database
- 查询ntopng Clickhouse数据库。
状态
适用于Claude Desktop应用程序和其他符合MCP标准的主机和客户端。
配置
- 创建或编辑位于以下位置的Claude Desktop配置文件:
- 在 macOS 上: ~/Library/Application Support/Claude/claude_desktop_config.json - 在Windows上: %APPDATA%/Claude/claude_desktop_config.json
- 添加以下内容:
{
"mcpServers": {
"mcp-ntopng": {
"command": "/path/to/your/uv-binary",
"args": ["run", "--with", "mcp-ntopng", "--python", "3.13", "mcp-ntopng"]
"env": {
"NTOPNG_HOST": "",
"NTOPNG_DBPORT": "",
"NTOPNG_DBUSER": "",
"NTOPNG_DBPASSWORD": "",
"NTOPNG_SECURE": "true",
"NTOPNG_VERIFY": "true",
"NTOPNG_CONNECT_TIMEOUT": "30",
"NTOPNG_SEND_RECEIVE_TIMEOUT": "300",
"NTOPNG_API_KEY": "NTOPNG_TOKEN"
}
}
}
}- 替换
/path/to/your/uv-binary通过绝对路径uv可执行。找到路径which uv这确保了正确的版本uv启动服务器时使用。
- 重新启动Claude Desktop以应用更改。
发展
- 在以下任一位置设置环境变量
claude_desktop_config.json文件或.env存储库根目录中的文件。
NTOPNG_HOST=localhost
NTOPNG_PORT=9000
NTOPNG_USER=default
NTOPNG_PASSWORD=- 跑
uv sync安装依赖项。安装uv按照说明 这里。那就去吧source .venv/bin/activate.
- 安装
mcp-ntopng包装带uv pip install -e .从项目主目录。
- 为了便于测试,您可以运行
mcp dev mcp_ntopng/mcp_server.py启动MCP服务器。 使用合适的聊天客户端进行更改
环境变量
以下环境变量用于配置数据库连接:
NTOPNG_HOST:主机名ntopng服务器NTOPNG_DBUSER:Clickhouse DB身份验证的用户名NTOPNG_DBPASSWORD:Clickhouse DB身份验证的密码NTOPNG_API_KEY:Thentopng身份验证令牌。
可选的
NTOPNG_DBPORT:Clickhouse数据库的端口号ntopng服务器
- 违约: 9000 如果启用了HTTPS, 8123 如果禁用 - 通常不需要设置,除非使用非标准端口
NTOPNG_SECURE:启用/禁用TLS连接
- 违约: false - 吃起来 true 用于安全的TLS连接
NTOPNG_VERIFY:启用/禁用SSL证书验证
- 违约: true - 设置为\`false以禁用证书验证(不建议用于生产)
NTOPNG_CONNECT_TIMEOUT:连接超时(秒)
- 默认值:\`30 - 如果遇到连接超时,请增加此值
NTOPNG_SEND_RECEIVE_TIMEOUT:发送/接收超时(秒)
- 违约: 300 - 为长时间运行的查询增加此值
检查 TLS设置 在 ntopng 有关设置到Clickhouse的TLS连接的详细信息的文档。发展
在本地计算机上安装软件包:
$ uv sync
$ uv pip install -e .运行MCP检查器
$ cd mcp_ntopng
$ source .env
$ CLIENT_PORT=8077 SERVER_PORT=8078 mcp dev run_mcp_ntopng.py --with clickhouse-driver --with python-dotenv --with uvicorn --with pip-system-certs使用Claude Desktop中的本地库。
查找:/用户/marco/库/应用程序\\支持/Claude/Claude_desktop_config json
编辑claude_desktop_config.json更改本地路径:
{
"mcpServers": {
"mcp-ntopng": {
"command": "/Users/marco/Development/claude/mcp-server-ntopng/.venv/bin/python",
"args": [
"/Users/marco/Development/claude/mcp-server-ntopng/run_mcp_ntopng.py"
],
"env": {
"NTOPNG_HOST": "marcoeg-nod004.ntoplink.com",
"NTOPNG_DBPORT": "9000",
"NTOPNG_DBUSER": "default",
"NTOPNG_DBPASSWORD": "",
"NTOPNG_SECURE": "false",
"NTOPNG_VERIFY": "false",
"NTOPNG_CONNECT_TIMEOUT": "30",
"NTOPNG_SEND_RECEIVE_TIMEOUT": "300",
"SELECT_QUERY_TIMEOUT_SECS": "30",
"NTOPNG_API_KEY": "NTOPNG_TOKEN"
}
}
}
}