生产力助手工具

一个基于Microsoft Agent Framework和自定义MCP服务器的个人生产力助手工具,提供笔记和任务管理功能。

  • by niket-sharma
  • C#
  • 本地部署
  • 更新于
在 GitHub 查看 niket-sharma/dotnet-productivity-agent-mcp

使用说明

生产力代理——微软代理框架+MCP

用C#构建的个人生产力助手。网8。它使用 Microsoft代理框架 (Microsoft.Agents.AI)作为人工智能的中坚力量和 自定义MCP服务器 通过stdio公开Notes和Tasks工具。

建筑

AgentClient (Microsoft Agent Framework)
    │
    │  AIAgent.RunStreamingAsync()
    │  — auto-invokes tools via function calling
    │
    ├── OpenAI / Azure OpenAI (LLM backend)
    │
    └── MCP Tools (from McpServer subprocess)
            │ stdio pipe
            ▼
        McpServer (.NET 8 console app)
            ├── NoteTools  → add_note, get_notes, search_notes
            └── TaskTools  → add_task, complete_task, get_tasks, get_current_time

项目

项目 角色
McpServer 自定义MCP服务器通过stdio公开Notes和Tasks工具
AgentClient AI代理应用程序——连接到MCP服务器,运行交互式聊天循环

先决条件

  • .NET 8 SDK
  • OpenAI API密钥(或Azure OpenAI)

设置

# 1. Clone the repo
git clone <repo-url>
cd dotnet-productivity-agent-mcp/ProductivityAgentSolution

# 2. Set your API key
cp .env.example .env   # then fill in your key
# or just:
export OPENAI_API_KEY="sk-..."

# 3. Build
dotnet build ProductivityAgentSolution.sln

# 4. Run
cd AgentClient
dotnet run

创建一个 .env 文件在 ProductivityAgentSolution/:

OPENAI_API_KEY=sk-...

运行前加载:

export $(cat .env | xargs)

可用工具

工具 说明
add_note 保存带有标题和内容的笔记
get_notes 检索所有已保存的笔记
search_notes 按关键字搜索笔记
add_task 添加具有优先级(低/中/高)的任务
complete_task 按任务ID标记已完成的任务
get_tasks 列出任务--筛选条件:全部、待处理、已完成、高、中、低
get_current_time 获取当前日期和时间

示例会话

You: Add three tasks: fix login bug (high), write unit tests (medium), update readme (low)
Assistant: Added 3 tasks:
  ⏳ [task_1] [HIGH] fix login bug
  ⏳ [task_2] [MEDIUM] write unit tests
  ⏳ [task_3] [LOW] update readme

You: Save a note — login bug is in AuthController.cs at line 47
Assistant: Note saved! [note_1] "Login Bug Location"

You: Complete task_1
Assistant: ✅ Task 'task_1' marked complete: 'fix login bug'

You: What time is it?
Assistant: Current time: Friday, February 28 2026 14:32:10

关键包

Azure OpenAI

在中交换客户端 AgentClient/Program.cs -代理API是相同的:

using Azure.AI.OpenAI;
using Azure.Identity;

AIAgent agent = new AzureOpenAIClient(
        new Uri(Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT")!),
        new AzureCliCredential())
    .GetChatClient("gpt-4o-mini")
    .AsIChatClient()
    .AsAIAgent(name: "ProductivityAssistant", instructions: "...", tools: [.. mcpTools]);