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
93e23eba
Commit
93e23eba
authored
May 06, 2025
by
何家明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整目录结构
parent
edd83aff
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
18 deletions
+38
-18
api.py
api.py
+14
-13
client.py
client/client.py
+2
-2
config.py
config/config.py
+4
-0
config.yaml
config/config.yaml
+2
-2
QueryParam.py
model/QueryParam.py
+0
-0
RestResult.py
model/RestResult.py
+11
-0
server.py
server/server.py
+5
-1
No files found.
api.py
View file @
93e23eba
...
...
@@ -2,25 +2,26 @@ import uvicorn
from
fastapi
import
FastAPI
from
fastapi.middleware.cors
import
CORSMiddleware
from
QueryParam
import
QueryParam
from
config_read
import
config
from
mcp_client
import
user_query
from
config.config
import
config
from
client.client
import
user_query
from
model.QueryParam
import
QueryParam
from
model.RestResult
import
RestResult
app
=
FastAPI
(
name
=
[
"BME MCP服务"
]
)
app
=
FastAPI
(
title
=
"BME MCP服务"
)
if
config
.
get
(
"cors"
):
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
config
.
get
(
"cors"
)
.
get
(
"allow_origins"
,
[
"*"
]),
allow_credentials
=
config
.
get
(
"cors"
)
.
get
(
"allow_credentials"
,
True
),
allow_methods
=
config
.
get
(
"cors"
)
.
get
(
"allow_methods"
,
[
"*"
]),
allow_headers
=
config
.
get
(
"cors"
)
.
get
(
"allow_headers"
,
[
"*"
]))
cors
=
config
.
get
(
"cors"
,
{})
app
.
add_middleware
(
CORSMiddleware
,
allow_origins
=
cors
.
get
(
"allow_origins"
,
[
"*"
]),
allow_credentials
=
cors
.
get
(
"allow_credentials"
,
True
),
allow_methods
=
cors
.
get
(
"allow_methods"
,
[
"*"
]),
allow_headers
=
cors
.
get
(
"allow_headers"
,
[
"*"
]))
@
app
.
post
(
path
=
"/mcp/query"
,
description
=
"调用mcp工具查询"
)
async
def
query
(
query_param
:
QueryParam
):
async
def
query
(
query_param
:
QueryParam
)
->
RestResult
:
if
query_param
.
customer_token
not
in
config
[
"customer"
]:
return
RestResult
(
code
=
403
,
message
=
"无权访问"
)
message
=
await
user_query
(
query_param
)
return
{
"message"
:
message
}
return
RestResult
(
code
=
200
,
message
=
message
)
if
__name__
==
"__main__"
:
...
...
mcp_
client.py
→
client/
client.py
View file @
93e23eba
...
...
@@ -13,8 +13,8 @@ from openai.types.chat.chat_completion_message_tool_call_param import Function
from
openai.types.shared_params
import
FunctionDefinition
from
pydantic
import
AnyUrl
from
QueryParam
import
QueryParam
from
config_read
import
config
from
config.config
import
config
from
model.QueryParam
import
QueryParam
if
config
[
"log"
][
"base_path"
]:
logger
.
add
(
config
[
"log"
][
"base_path"
]
+
"/mcp_client/log_{time:
%
Y-
%
m-
%
d}.log"
,
rotation
=
"1 day"
,
encoding
=
"utf-8"
,
...
...
config
_read
.py
→
config
/config
.py
View file @
93e23eba
import
yaml
with
open
(
"config.yaml"
,
"r"
,
encoding
=
"utf-8"
)
as
yml_file
:
with
open
(
"
./config/
config.yaml"
,
"r"
,
encoding
=
"utf-8"
)
as
yml_file
:
config
=
yaml
.
safe_load
(
yml_file
)
config.yaml
→
config
/config
.yaml
View file @
93e23eba
...
...
@@ -9,7 +9,7 @@ model:
# 公司:qwen3-32b
bme-qwen3-32b
:
api_key
:
Tc7sY47hiU5d1LNGbJjGBfqfY13IE3khIc0uBvpJ11U
base_url
:
http://10.10.10.
43:11434
/v1
base_url
:
http://10.10.10.
14:30300
/v1
model_name
:
qwen3:32b
# 公司:deepseek-v3-0324-671b
bme-deepseek-v3-0324-671b
:
...
...
@@ -20,7 +20,7 @@ server:
# 运行命令
command
:
python
args
:
-
mcp_
server.py
-
./server/
server.py
tool_calls_deep
:
20
# tool_call调用深度
log
:
base_path
:
log
...
...
QueryParam.py
→
model/
QueryParam.py
View file @
93e23eba
File moved
model/RestResult.py
0 → 100644
View file @
93e23eba
from
pydantic
import
BaseModel
class
RestResult
(
BaseModel
):
"""返回实体"""
code
:
int
=
200
"""状态码"""
message
:
str
"""返回信息"""
\ No newline at end of file
mcp_
server.py
→
server/
server.py
View file @
93e23eba
import
os
import
sys
import
requests
from
mcp.server.fastmcp
import
FastMCP
from
config_read
import
config
sys
.
path
.
append
(
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"../"
)))
from
config.config
import
config
mcp
=
FastMCP
(
"BME-MCP"
)
...
...
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