TeddyBot
使用Semantic Kernel和Microsoft构建的AI控制台应用程序。扩展。AI,具有MCP(模型上下文协议)工具集成功能。
特性
- 对话式人工智能 -聊天时保持上下文不变
- 工具调用 -通过MCP服务器自动调用功能
- 文件系统访问 -读取、写入、搜索和管理允许目录中的文件
- 可扩展架构 -为添加子代理、工具和评估而构建
技术栈
| 组件 | 技术 |
|---|---|
| 框架 | 。净值10.0 |
| AI编排 | 语义内核 1.68.0 |
| 抽象 | 微软。扩展。人工智能 10.0.1 |
| 工具协议 | 模型上下文协议(MCP) |
| LLM提供商 | Azure OpenAI(gpt-4.1-mini) |
| 托管 | 微软。扩展。托管服务 |
项目结构
TeddyBot/
├── Program.cs # Entry point with DI host setup
├── appsettings.json # Configuration
├── Configuration/
│ ├── AzureOpenAISettings.cs # Azure OpenAI connection settings
│ ├── TeddyBotSettings.cs # Agent name and system prompt
│ └── McpSettings.cs # MCP server configuration
├── Agents/
│ ├── ITeddyAgent.cs # Agent abstraction
│ └── TeddyAgent.cs # ChatCompletionAgent wrapper
├── Services/
│ ├── IChatService.cs # Chat orchestration interface
│ ├── ChatService.cs # Message handling
│ └── ConversationContext.cs # Conversation state
├── Plugins/
│ └── McpPluginLoader.cs # MCP tool loader
├── Hosting/
│ └── TeddyBotHostedService.cs # Console interaction loop
└── workspace/ # Directory for file operations入门指南
先决条件
- .NET 10.0 SDK
- (通过npx用于MCP文件系统服务器)
- Azure OpenAI资源或Azure AI Foundry项目
配置
- 设置您的Azure OpenAI凭据:
cd TeddyBot
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://your-resource.cognitiveservices.azure.com/"
dotnet user-secrets set "AzureOpenAI:ApiKey" "your-api-key"- 更新
appsettings.json如果使用不同的模型部署:
"AzureOpenAI": {
"DeploymentName": "your-deployment-name",
"ModelId": "your-model-id"
}跑步
cd TeddyBot
dotnet run命令:
- 键入您的信息,然后按Enter键聊天
clear-重置对话历史记录exit-退出应用程序
示例用法
You: What can you do?
TeddyBot: I can assist you with questions, writing, and file operations...
You: Create a file called notes.txt with "Meeting at 3pm"
TeddyBot: I have created notes.txt with your content.
You: List files in workspace
TeddyBot: There is one file: notes.txt可用的MCP工具
文件系统MCP服务器提供14个工具:
| 工具 | 说明 |
|---|---|
read_file | 读取文件内容 |
write_file | 创建或覆盖文件 |
read_multiple_files | 一次读取多个文件 |
create_directory | 创建新目录 |
list_directory | 列出目录内容 |
move_file | 移动或重命名文件 |
search_files | 按模式搜索文件 |
get_file_info | 获取文件元数据 |
list_allowed_directories | 显示可访问的目录 |
| 还有更多。.. |
路线图
计划的功能
- \[ \] 多个子代理 -不同任务(编码、研究等)的专业代理
- \[ \] 其他MCP服务器 -GitHub、SQLite、网页浏览和自定义工具
- \[ \] 自定义插件 -原生C#插件
[KernelFunction]属性 - \[ \] 代理商评估 -微软。扩展。AI.用于衡量绩效的评估集成
- \[ \] 快速迭代 -基于评估指标的数据驱动提示优化
- \[ \] 内存/RAG -长期记忆和检索增强生成
- \[ \] 多轮次规划 -复杂任务分解和执行
未来整合
- \[\]Azure AI代工厂
- \[\]开放遥测可观察性
- \[\]结构化输出/JSON模式
- \[\]图像和多模式支持
建筑
┌─────────────────────────────────────────────────────────┐
│ TeddyBotHostedService │
│ (Console Loop) │
└─────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ ChatService │
│ (Message Orchestration) │
└─────────────────────┬───────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────┐
│ TeddyAgent │
│ (ChatCompletionAgent Wrapper) │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Semantic Kernel │ │
│ │ ┌─────────────┐ ┌──────────────────────────┐ │ │
│ │ │ Azure OpenAI│ │ MCP Plugins │ │ │
│ │ │ Service │ │ (filesystem, etc.) │ │ │
│ │ └─────────────┘ └──────────────────────────┘ │ │
│ └─────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘添加MCP服务器
编辑 appsettings.json 要添加更多MCP服务器:
"Mcp": {
"Servers": [
{
"Name": "filesystem",
"Command": "npx",
"Arguments": ["-y", "@modelcontextprotocol/server-filesystem", "./workspace"],
"Enabled": true
},
{
"Name": "github",
"Command": "npx",
"Arguments": ["-y", "@modelcontextprotocol/server-github"],
"Enabled": true
}
]
}许可证
麻省理工学院
