project basic
This commit is contained in:
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
# Python-generated files
|
||||||
|
__pycache__/
|
||||||
|
*.py[oc]
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
wheels/
|
||||||
|
*.egg-info
|
||||||
|
|
||||||
|
# Virtual environments
|
||||||
|
.venv
|
||||||
1
.python-version
Normal file
1
.python-version
Normal file
@@ -0,0 +1 @@
|
|||||||
|
3.13
|
||||||
15
pyproject.toml
Normal file
15
pyproject.toml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[project]
|
||||||
|
name = "login-mcp"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Add your description here"
|
||||||
|
readme = "README.md"
|
||||||
|
requires-python = ">=3.13"
|
||||||
|
dependencies = [
|
||||||
|
"fastmcp>=2.11.3",
|
||||||
|
"langchain>=0.3.27",
|
||||||
|
"langchain-ollama>=0.3.7",
|
||||||
|
"langgraph>=0.6.6",
|
||||||
|
"mcpstore>=1.4.27",
|
||||||
|
"python-dotenv>=1.1.1",
|
||||||
|
"requests>=2.32.5",
|
||||||
|
]
|
||||||
11
src/login_test.py
Normal file
11
src/login_test.py
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import requests
|
||||||
|
payload={
|
||||||
|
'username':'user@example.com',
|
||||||
|
'password':'stringt'
|
||||||
|
}
|
||||||
|
|
||||||
|
url = 'http://localhost:8000/api/v1/login/access-token'
|
||||||
|
|
||||||
|
response = requests.post(url,data=payload)
|
||||||
|
|
||||||
|
print(response.text)
|
||||||
35
src/mcp_server.py
Normal file
35
src/mcp_server.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
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://localhost: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:用户的密码
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
31
src/ollama_agent.py
Normal file
31
src/ollama_agent.py
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
from langchain_ollama import ChatOllama
|
||||||
|
from langgraph.prebuilt import create_react_agent
|
||||||
|
from mcpstore import MCPStore
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
import os
|
||||||
|
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
remote_ollama_url = os.environ.get("remote_ollama_url")
|
||||||
|
|
||||||
|
llm = ChatOllama(
|
||||||
|
model="qwen3:8b",
|
||||||
|
base_url=remote_ollama_url,
|
||||||
|
temperature=0.1,
|
||||||
|
)
|
||||||
|
|
||||||
|
store_mcp = MCPStore.setup_store()
|
||||||
|
store_mcp.for_store().add_service(
|
||||||
|
config=[
|
||||||
|
{'name':'登陆助手','url':''}
|
||||||
|
]
|
||||||
|
)
|
||||||
|
tools = store_mcp.for_store().for_langchain().list_tools()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
12
src/register_test.py
Normal file
12
src/register_test.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import requests
|
||||||
|
payload={
|
||||||
|
'email':'bbxx@qq.com',
|
||||||
|
"full_name": "string",
|
||||||
|
'password':'stringt123'
|
||||||
|
}
|
||||||
|
|
||||||
|
url = 'http://localhost:8000/api/v1/users/signup'
|
||||||
|
|
||||||
|
response = requests.post(url,json=payload)
|
||||||
|
|
||||||
|
print(response.text)
|
||||||
0
src/webui.py
Normal file
0
src/webui.py
Normal file
Reference in New Issue
Block a user