人员与文档搜索代理工具

一个开源的代理工具,用于在HR数据库中查找人员并搜索相关文档,支持SQLite数据库和全文搜索功能。

  • by daviddata-cloud
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 daviddata-cloud/agent_skill_mcp_project

使用说明

Agent Skill Demo: Find Person (DB MCP) → Search Docs (Doc MCP)

This repository is a fully open-source, runnable example of an "agent skill" that composes two local MCP servers over stdio (newline-delimited JSON-RPC 2.0): Note: dummy/public/synthetic data only in this project.

  1. DB MCP: loads an HR people.csv (with 3 metadata lines) into SQLite and exposes read-only tools.
  2. Doc MCP: exposes local docs as MCP resources and provides full-text search (SQLite FTS5 when available).

The agent workflow:

  1. Find a person in HR (DB MCP)
  2. Search documentation for that person (Doc MCP)

No Claude/Desktop setup required. No proprietary SDKs.


Quick start

1) Run the agent demo

python agent.py --person "Ava"
python agent.py --person "Ava Nguyen" --show-doc
python agent.py --person "ava.nguyen@example.org"

Output is JSON describing:

  • all matching people
  • the selected person
  • doc search results (and optionally top document text)

2) Rebuild the documentation index (after adding docs)

If you add .md or .txt files in ./doc_mcp/docs/, rebuild the index:

python doc_mcp/build_doc_index.py --docs_dir ./doc_mcp/docs --out_map ./doc_mcp/doc_map.json --out_db ./doc_mcp/doc_index.sqlite

Project layout

  • agent.py — the "skill" orchestrator
  • mcp_stdio_client.py — minimal MCP stdio client helper
  • db_mcp/ — DB MCP server + sample HR CSV
  • doc_mcp/ — Documentation MCP server + docs + search index

Notes

  • The sample HR CSV is synthetic.
  • The DB MCP server enforces read-only SQL (SELECT/WITH only).
  • The Doc MCP server supports:
    • doc_search tool (FTS when available)
    • doc_read tool
    • resources/list and resources/read

License

run samples

C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project>python enterprise_demo.py --person "Ava Nguyen" --destination Chicago --date 2026-03-12 --auto-approve
[db_mcp] [db_mcp_server] Ready. Loaded C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project\db_mcp\data\hr_people.csv. Tools: 4
[doc_mcp] [doc_mcp_server] Loaded 4 docs. FTS5=yes
[doc_mcp] [doc_mcp_server] Ready.
[flight_mcp] [flight_mcp] Loaded 8 flights from C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project\flight_mcp\data\flights.json
[flight_mcp] [flight_mcp] Ready.
{
  "request": {
    "person_query": "Ava Nguyen",
    "destination": "Chicago",
    "destination_airport": "ORD",
    "date": "2026-03-12"
  },
  "traveler": {
    "employee_id": 1001,
    "full_name": "Ava Nguyen",
    "email": "ava.nguyen@example.org",
    "department": "Engineering",
    "title": "Software Engineer",
    "location": "New York",
    "manager_id": 2001
  },
  "manager": {
    "employee_id": 2001,
    "full_name": "Ethan Smith",
    "email": "ethan.smith@example.org"
  },
  "policy": {
    "queries": [
      "Corporate Travel Policy airfare under",
      "Airfare guideline under $",
      "manager approval airfare",
      "travel policy"
    ],
    "hits": [
      {
        "query": "Corporate Travel Policy airfare under",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 19.170664591865652,
            "snippet": "# [Corporate] [Travel] [Policy] (Demo)\n\nThis is a **synthetic** [policy] document used for demonstrating an open-source…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      },
      {
        "query": "manager approval airfare",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 9.134674235279132,
            "snippet": "…[airfare] should normally be **under $600 USD**.\n- Any [airfare] **over $600 USD** requires **[manager] [approval]**.\n- Keep…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      },
      {
        "query": "travel policy",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 8.928491582511208,
            "snippet": "# Corporate [Travel] [Policy] (Demo)\n\nThis is a **synthetic** [policy] document used for demonstrating an open-source…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      }
    ],
    "parsed": {
      "max_airfare_usd": 600,
      "doc_id": "travel-policy",
      "snippet": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any "
    }
  },
  "selected_flight": {
    "flight_id": "F1001",
    "airline": "United",
    "flight_number": "UA101",
    "origin": "JFK",
    "destination": "ORD",
    "depart_date": "2026-03-12",
    "depart_time": "08:00",
    "arrive_time": "09:45",
    "cabin": "economy",
    "refundable": false,
    "price_usd": 320
  },
  "hold": {
    "hold_id": "H1770395495-1067",
    "expires_at": 1770397295,
    "flight": {
      "flight_id": "F1001",
      "airline": "United",
      "flight_number": "UA101",
      "origin": "JFK",
      "destination": "ORD",
      "depart_date": "2026-03-12",
      "depart_time": "08:00",
      "arrive_time": "09:45",
      "cabin": "economy",
      "refundable": false,
      "price_usd": 320
    }
  },
  "booking": {
    "booking": {
      "booking_id": "B1770395495-5619",
      "hold_id": "H1770395495-1067",
      "flight_id": "F1001",
      "traveler": {
        "employee_id": 1001,
        "name": "Ava Nguyen",
        "email": "ava.nguyen@example.org"
      },
      "created_at": 1770395495,
      "requested_by": "enterprise_demo",
      "status": "booked"
    },
    "flight": {
      "flight_id": "F1001",
      "airline": "United",
      "flight_number": "UA101",
      "origin": "JFK",
      "destination": "ORD",
      "depart_date": "2026-03-12",
      "depart_time": "08:00",
      "arrive_time": "09:45",
      "cabin": "economy",
      "refundable": false,
      "price_usd": 320
    }
  },
  "transcript": [
    {
      "agent": "hr_agent",
      "message": "Found traveler: Ava Nguyen (1001), Software Engineer, New York."
    },
    {
      "agent": "hr_agent",
      "message": "Manager: Ethan Smith (2001), email=ethan.smith@example.org."
    },
    {
      "agent": "coordinator",
      "message": "Trip request: JFK → ORD on 2026-03-12 for Ava Nguyen."
    },
    {
      "agent": "policy_agent",
      "message": "Parsed travel policy max domestic airfare: $600 (economy)."
    },
    {
      "agent": "travel_agent",
      "message": "Found 3 flight option(s) for JFK->ORD on 2026-03-12."
    },
    {
      "agent": "travel_agent",
      "message": "Selected flight UA101 ($320) departing 08:00."
    },
    {
      "agent": "travel_agent",
      "message": "Placed hold: H1770395495-1067"
    },
    {
      "agent": "approver",
      "message": "Approval decision: APPROVED (auto_approve)."
    }
  ]


  -interactive
**  C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project>python enterprise_demo.py --person "Ava Nguyen" --destination Chicago --date 2026-03-12**
[db_mcp] [db_mcp_server] Ready. Loaded C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project\db_mcp\data\hr_people.csv. Tools: 4
[doc_mcp] [doc_mcp_server] Loaded 4 docs. FTS5=yes
[doc_mcp] [doc_mcp_server] Ready.
[flight_mcp] [flight_mcp] Loaded 8 flights from C:\Users\davidzhang\Downloads\ml\ml\enterprise_agent_poc_project\flight_mcp\data\flights.json
[flight_mcp] [flight_mcp] Ready.
**Approve booking for Ava Nguyen on UA101 ($320)? [y/N]: y**
{
  "request": {
    "person_query": "Ava Nguyen",
    "destination": "Chicago",
    "destination_airport": "ORD",
    "date": "2026-03-12"
  },
  "traveler": {
    "employee_id": 1001,
    "full_name": "Ava Nguyen",
    "email": "ava.nguyen@example.org",
    "department": "Engineering",
    "title": "Software Engineer",
    "location": "New York",
    "manager_id": 2001
  },
  "manager": {
    "employee_id": 2001,
    "full_name": "Ethan Smith",
    "email": "ethan.smith@example.org"
  },
  "policy": {
    "queries": [
      "Corporate Travel Policy airfare under",
      "Airfare guideline under $",
      "manager approval airfare",
      "travel policy"
    ],
    "hits": [
      {
        "query": "Corporate Travel Policy airfare under",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 19.170664591865652,
            "snippet": "# [Corporate] [Travel] [Policy] (Demo)\n\nThis is a **synthetic** [policy] document used for demonstrating an open-source…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      },
      {
        "query": "manager approval airfare",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 9.134674235279132,
            "snippet": "…[airfare] should normally be **under $600 USD**.\n- Any [airfare] **over $600 USD** requires **[manager] [approval]**.\n- Keep…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      },
      {
        "query": "travel policy",
        "matches": [
          {
            "doc_id": "travel-policy",
            "title": "Corporate Travel Policy (Demo)",
            "chunk_id": 0,
            "score": 8.928491582511208,
            "snippet": "# Corporate [Travel] [Policy] (Demo)\n\nThis is a **synthetic** [policy] document used for demonstrating an open-source…",
            "text": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any action that commits spending (e.g., ticket purchase) must include a **human approval step**.\n\n"
          }
        ]
      }
    ],
    "parsed": {
      "max_airfare_usd": 600,
      "doc_id": "travel-policy",
      "snippet": "# Corporate Travel Policy (Demo)\n\nThis is a **synthetic** policy document used for demonstrating an open-source MCP documentation server.\n\n## Booking rules\n\n- Book **economy cabin** by default for domestic travel.\n- Prefer the **lowest logical fare** that meets business needs.\n- **Airfare guideline:** domestic economy airfare should normally be **under $600 USD**.\n- Any airfare **over $600 USD** requires **manager approval**.\n- Keep receipts and include the **booking ID** in the expense report.\n\n## Safety / approvals\n\n- Automated agents may **search** and **prepare** travel itineraries.\n- Any "
    }
  },
  "selected_flight": {
    "flight_id": "F1001",
    "airline": "United",
    "flight_number": "UA101",
    "origin": "JFK",
    "destination": "ORD",
    "depart_date": "2026-03-12",
    "depart_time": "08:00",
    "arrive_time": "09:45",
    "cabin": "economy",
    "refundable": false,
    "price_usd": 320
  },
  "hold": {
    "hold_id": "H1770395562-5498",
    "expires_at": 1770397362,
    "flight": {
      "flight_id": "F1001",
      "airline": "United",
      "flight_number": "UA101",
      "origin": "JFK",
      "destination": "ORD",
      "depart_date": "2026-03-12",
      "depart_time": "08:00",
      "arrive_time": "09:45",
      "cabin": "economy",
      "refundable": false,
      "price_usd": 320
    }
  },
  "booking": {
    "booking": {
      "booking_id": "B1770395570-7875",
      "hold_id": "H1770395562-5498",
      "flight_id": "F1001",
      "traveler": {
        "employee_id": 1001,
        "name": "Ava Nguyen",
        "email": "ava.nguyen@example.org"
      },
      "created_at": 1770395570,
      "requested_by": "enterprise_demo",
      "status": "booked"
    },
    "flight": {
      "flight_id": "F1001",
      "airline": "United",
      "flight_number": "UA101",
      "origin": "JFK",
      "destination": "ORD",
      "depart_date": "2026-03-12",
      "depart_time": "08:00",
      "arrive_time": "09:45",
      "cabin": "economy",
      "refundable": false,
      "price_usd": 320
    }
  },
  "transcript": [
    {
      "agent": "hr_agent",
      "message": "Found traveler: Ava Nguyen (1001), Software Engineer, New York."
    },
    {
      "agent": "hr_agent",
      "message": "Manager: Ethan Smith (2001), email=ethan.smith@example.org."
    },
    {
      "agent": "coordinator",
      "message": "Trip request: JFK → ORD on 2026-03-12 for Ava Nguyen."
    },
    {
      "agent": "policy_agent",
      "message": "Parsed travel policy max domestic airfare: $600 (economy)."
    },
    {
      "agent": "travel_agent",
      "message": "Found 3 flight option(s) for JFK->ORD on 2026-03-12."
    },
    {
      "agent": "travel_agent",
      "message": "Selected flight UA101 ($320) departing 08:00."
    },
    {
      "agent": "travel_agent",
      "message": "Placed hold: H1770395562-5498"
    },
    {
      "agent": "approver",
      "message": "Approval decision: APPROVED (interactive_prompt)."
    }
  ]
}




MIT