Initial commit: test-conflict-agent with 0 tools - src/server/mcp_server.py

This commit is contained in:
2026-01-30 12:30:20 +00:00
parent 09b994d4e2
commit d1d0598f1d
+77
View File
@@ -0,0 +1,77 @@
"""
MCP 服务器 - test-conflict-agent
Agent with 0 external tools
使用 Pydantic AI 和 FastMCP 框架。
自动生成时间: 2026-01-30T12:30:18.247341
"""
import json
import os
from typing import Optional
from mcp.server.fastmcp import FastMCP
from pydantic_ai import Agent
# ==================== 配置 ====================
# LiteLLM Gateway 配置
_BASE_URL = os.getenv('OPENAI_BASE_URL',
os.getenv('LLM_BASE_URL', 'https://litellm.graystone-fb459c5d.southeastasia.azurecontainerapps.io/v1'))
_API_KEY = os.getenv('OPENAI_API_KEY', 'sk')
os.environ.setdefault('OPENAI_API_KEY', _API_KEY)
os.environ.setdefault('OPENAI_BASE_URL', _BASE_URL)
# 模型名称(pydantic_ai 需要 openai: 前缀)
def _get_model_name() -> str:
model = os.getenv('MODEL_NAME', os.getenv('LITELLM_MODEL', 'taiji/gpt-4o-mini'))
return model if ':' in model else f'openai:{model}'
MODEL_NAME = _get_model_name()
# ==================== MCP 服务器 ====================
server = FastMCP('test-conflict-agent')
# 系统提示词
SYSTEM_PROMPT = """你是 test-conflict-agent,一个专业的 AI 智能助手。
## 角色定位
Agent with 0 external tools
## 可用工具
## 工作原则
1. 理解用户意图:仔细分析用户的请求,确保准确理解需求
2. 选择合适工具:根据需求选择最合适的工具来完成任务
3. 清晰反馈:以用户友好的方式呈现结果
4. 错误处理:遇到问题时提供有用的错误信息和建议
## 响应格式
- 对于数据查询:返回结构化的 JSON 数据
- 对于操作请求:返回操作状态和结果
- 始终使用中文与用户交流(除非用户使用其他语言)"""
def get_agent() -> Agent:
"""创建 Agent 实例(每次调用使用最新的 API Key)"""
return Agent(MODEL_NAME, system_prompt=SYSTEM_PROMPT)
# ==================== MCP 工具定义 ====================
# ==================== 工具映射(供 API 使用)====================
TOOL_MAP = {
}
TOOL_LIST = [
]
if __name__ == '__main__':
server.run()