Files
login_regist_mcp/src/mcp_server.py
ext-ensky-jeremy.jj.he 9cf76a8417 add feature bulding
2025-08-29 17:30:00 +08:00

40 lines
955 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from mcp.server.fastmcp import FastMCP
import requests
mcp = FastMCP(name='FastMCP',host='0.0.0.0',port=8000)
@mcp.tool()
def login_function(username:str, password:str) -> dict :
"""
功能:
接受账号密码调用登陆api发送调用结果并展示调用输出。
参数:
username:用户的账号,或者是用户名称
password:用户的密码
"""
payload={
'username':username,
'password':password
}
url = 'http://192.168.50.11:8000/api/v1/login/access-token'
response = requests.post(url,data=payload)
return response.text
@mcp.tool()
def register_function(username:str, password:str):
"""
功能:
注册用户调用注册api进行新用户注册。+
参数:
username:用户的账号,或者是用户名称
password:用户的密码
"""
if __name__=='__main__':
mcp.run(transport='streamable-http')