Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bme-mcp
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
何家明
bme-mcp
Commits
e7d4538d
Commit
e7d4538d
authored
Oct 20, 2025
by
何家明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增除尘器停止状态的查询接口
parent
c3760ffa
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
13 deletions
+45
-13
README.md
README.md
+3
-5
api.py
api.py
+1
-1
config.yaml
config/config.yaml
+1
-0
system.py
config/system.py
+6
-1
server.py
server/server.py
+34
-6
No files found.
README.md
View file @
e7d4538d
...
...
@@ -20,11 +20,9 @@ python api.py
启动成功后,可以调用接口
```
post http://localhost:8000/mcp/query
{
"message": "治理过程全记录",
"customer_token": "ef616aad53d3eddfb53ca71980421440"
}
get localhost:8000/mcp/chat?message=xxx
注意要给header中加一个参数id,代表客户id
```
## config.yaml
...
...
api.py
View file @
e7d4538d
...
...
@@ -23,7 +23,7 @@ async def lifespan(app):
api
=
FastAPI
(
title
=
"BME MCP服务"
,
lifespan
=
lifespan
)
router
=
APIRouter
(
prefix
=
"/mcp
/
"
)
router
=
APIRouter
(
prefix
=
"/mcp"
)
@
router
.
get
(
"/chat/logo"
)
async
def
get_ai_logo
():
...
...
config/config.yaml
View file @
e7d4538d
...
...
@@ -42,6 +42,7 @@ remote:
base_url
:
bme-screen-service
:
https://vis.bmetech.com/vis
# bme-screen-service: http://localhost:9070/screen
bme-pc-service
:
https://vis.bmetech.com/vispc
# 跨域配置
cors
:
...
...
config/system.py
View file @
e7d4538d
import
yaml
import
os
with
open
(
"./config/config.yaml"
,
"r"
,
encoding
=
"utf-8"
)
as
yml_file
:
current_dir
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
yaml_path
=
os
.
path
.
join
(
current_dir
,
"../config/config.yaml"
)
yaml_path
=
os
.
path
.
normpath
(
yaml_path
)
with
open
(
yaml_path
,
"r"
,
encoding
=
"utf-8"
)
as
yml_file
:
config
=
yaml
.
safe_load
(
yml_file
)
server/server.py
View file @
e7d4538d
import
os
import
sys
from
typing
import
List
,
Any
import
requests
from
mcp.server.fastmcp
import
FastMCP
...
...
@@ -45,7 +46,7 @@ def get_size_limit(size: int, max_size=20, min_size=0) -> int:
@
mcp
.
tool
()
def
get_air_pm_10_month_focus
(
customer_id
:
int
)
->
[]
:
def
get_air_pm_10_month_focus
(
customer_id
:
int
)
->
Any
:
"""
根据客户id获取本月重点关注的空气质量微站(PM10标准)
:param customer_id: 客户id
...
...
@@ -68,7 +69,7 @@ def get_air_pm_10_month_focus(customer_id: int) -> []:
@
mcp
.
tool
()
def
get_air_pm_rank
(
customer_id
:
int
,
order
:
int
,
statistic_type
:
int
)
->
[]
:
def
get_air_pm_rank
(
customer_id
:
int
,
order
:
int
,
statistic_type
:
int
)
->
Any
:
"""
根据客户id获取空气质量微站排行(包含PM2.5和PM10标准),其中
order如果没有指定,默认值是1;
...
...
@@ -106,7 +107,7 @@ def get_air_pm_rank(customer_id: int, order: int, statistic_type: int) -> []:
@
mcp
.
tool
()
def
get_tsp_rank
(
customer_id
:
int
,
order
:
int
,
statistic_type
:
int
,
size
:
int
)
->
[]
:
def
get_tsp_rank
(
customer_id
:
int
,
order
:
int
,
statistic_type
:
int
,
size
:
int
)
->
Any
:
"""
根据客户id获取TSP监测排行,其中
order如果没有指定,默认值是1;
...
...
@@ -150,7 +151,7 @@ def get_tsp_rank(customer_id: int, order: int, statistic_type: int, size: int) -
@
mcp
.
tool
()
def
get_governance_process_statistics
(
customer_id
:
int
)
->
{}
:
def
get_governance_process_statistics
(
customer_id
:
int
)
->
Any
:
"""
根据客户id获取今天治理过程记录统计数据
:param customer_id: 客户id
...
...
@@ -171,7 +172,7 @@ def get_governance_process_statistics(customer_id: int) -> {}:
@
mcp
.
tool
()
def
get_governance_process_records
(
customer_id
:
int
,
instruct_type
:
str
,
device_name
:
str
,
start_time
:
str
,
end_time
:
str
,
size
:
int
)
->
[]
:
start_time
:
str
,
end_time
:
str
,
size
:
int
)
->
Any
:
"""
根据客户id查询治理过程全记录,其中:
instruct_type如果没有指定,默认值是空字符串;
...
...
@@ -218,8 +219,35 @@ def get_governance_process_records(customer_id: int, instruct_type: str, device_
return
result
@
mcp
.
tool
()
def
get_stopped_dust_collector
(
customer_id
:
int
)
->
Any
:
"""
根据客户id获取当前已停止的除尘器
:param customer_id: 客户id
:return: 返回结构中的字段名解释:
name: 所在区域
deviceName: 除尘器名称
deviceNo: 除尘器编码
type: 除尘器类型
"""
response
=
requests
.
get
(
bme_screen_service
+
"/treatment/cc_list"
,
{
"customerId"
:
customer_id
,
"pageNo"
:
1
,
"pageSize"
:
50
,
"status"
:
0
},
headers
=
headers
)
response_data
=
deal_request_exception
(
response
)
.
get
(
"data"
,
{})
.
get
(
"records"
,
[])
result
=
[{
"name"
:
record
.
get
(
"name"
),
"deviceName"
:
record
.
get
(
"deviceName"
),
"deviceNo"
:
record
.
get
(
"deviceNo"
),
"type"
:
record
.
get
(
"type"
)
}
for
record
in
response_data
]
return
result
@
mcp
.
resource
(
"api://customers"
)
def
get_all_available_customer
()
->
[]
:
def
get_all_available_customer
()
->
Any
:
"""
获取所有的客户信息
:return: 客户信息数据
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment