Skip to main content

HiAgent MCP Server

This MCP server wraps HiAgent Platform OpenAPI capabilities as MCP tools. It currently provides knowledge-engine tools — listing knowledge bases (datasets) in a workspace, inspecting a dataset, and calling the HiAgent knowledge engine to retrieve knowledge chunks — and will keep adding more HiAgent OpenAPI capabilities over time.

Features

  • List knowledge bases (datasets) in a workspace
  • Inspect a single dataset, including its default retrieval parameters
  • Search knowledge in one or more datasets via the knowledge engine (knowledge_search)
  • Report MCP server and OpenAPI configuration state

Setup

Prerequisites

  • Python 3.11 or higher
  • API credentials (AK/SK)

Installation

Run directly from the repository with uvx (recommended):

uvx --from "git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_hiagent" mcp-server-hiagent

Or with uv, from the compatibility path:

cd mcp-server/server/mcp_server_hiagent
uv run mcp-server-hiagent

Configuration

The server requires the following environment variables:

  • HIAGENT_TOP_HOST: HiAgent Platform API (volc-top) gateway address, including scheme and port
  • HIAGENT_ACCESS_KEY_ID: Your HiAgent access key id
  • HIAGENT_SECRET_ACCESS_KEY: Your HiAgent secret access key

Optional environment variables:

  • HIAGENT_VERSION: HiAgent OpenAPI compatibility version to use. Defaults to the latest registered version (currently v3.1.0). Can also be set per-run with the --hiagent-version CLI flag, which takes precedence. Selects a self-contained implementation under versions/; supported values: v3.1.0
  • HIAGENT_ACCOUNT_ID: Main account id sent as the X-Account-Id query parameter, defaults to 1000000000
  • HIAGENT_REGION: Region used in AK/SK V4 signing (not a network address), defaults to cn-north-1
  • FASTMCP_CHECK_FOR_UPDATES: Set to off to skip FastMCP's startup update check, which otherwise makes an outbound request and can fail startup in restricted networks
  • MCP_SERVER_HOST: Bind host for the FastMCP server, streamable-http only (default: 127.0.0.1)
  • MCP_SERVER_PORT: Bind port for the FastMCP server, streamable-http only (default: 8000)
  • STREAMABLE_HTTP_PATH: Streamable HTTP endpoint path (default: /mcp)

Usage

Running the Server

The server can be run with either stdio transport (for MCP integration, e.g. the HiAgent STDIO plugin) or streamable-http transport:

python -m mcp_server_hiagent.main --transport stdio

Or:

python -m mcp_server_hiagent.main --transport streamable-http

Select a specific HiAgent OpenAPI version explicitly with --hiagent-version (overrides the HIAGENT_VERSION environment variable; defaults to the latest registered version):

python -m mcp_server_hiagent.main --hiagent-version v3.1.0

Available Tools

health_check

Report the MCP server and OpenAPI configuration state.

health_check()

list_datasets

List knowledge bases (datasets) in a workspace, so callers can obtain the DatasetIDs required by the knowledge engine.

list_datasets(
    workspace_id="workspace_id",
    page_number=1,
    page_size=20,
)

Parameters:

  • workspace_id (required): the workspace id to list datasets for.
  • page_number (optional): page number (default: 1).
  • page_size (optional): page size (default: 20).

get_dataset

Get information about a single dataset, including its default retrieval parameters.

get_dataset(
    workspace_id="workspace_id",
    dataset_id="dataset_id",
)

Parameters:

  • workspace_id (required): the workspace id the dataset belongs to.
  • dataset_id (required): the id of the dataset to inspect.

call_knowledge_engine_tool

Call the HiAgent knowledge engine over one or more datasets. Only tool_name="knowledge_search" is supported at present.

call_knowledge_engine_tool(
    workspace_id="workspace_id",
    dataset_ids=["dataset_id"],
    tool_name="knowledge_search",
    queries=["How to reset my password?"],
    top_k=3,
    score_threshold=0.2,
)

Parameters:

  • workspace_id (required): the workspace id the datasets belong to.
  • dataset_ids (required): list of dataset ids to search, at least one.
  • tool_name (optional): sub-tool name, defaults to knowledge_search. Only knowledge_search is supported at present; other known sub-tools (list_knowledge_chunks, grep_chunks, get_doc_info, wiki_search, wiki_read_page, wiki_read_source_doc) are recognized but rejected.
  • queries (optional): list of query strings (required for knowledge_search).
  • top_k (optional): maximum number of results to return.
  • score_threshold (optional): relevance score threshold (0~1).
  • rerank_id (optional): rerank model id.
  • knowledge_run_mode (optional): run mode, one of quick / smart_search / wiki_search.

Best Practices & Test Prompts

Recommended usage pattern and, for each exposed tool, a natural-language prompt you can give an MCP-enabled agent to exercise it plus the expected result. These prompts double as a manual smoke test after wiring the server into a client.

Recommended flow: health_check (confirm config) → list_datasets (discover DatasetIDs) → optionally get_dataset (read default retrieval params) → call_knowledge_engine_tool (retrieve). WorkspaceID is not discoverable via this server — take it from the HiAgent console URL (.../workspace/<id>/...).

health_check

  • Best practice: call it first, before any credentialed tool, to confirm the server sees your AK/SK and top host. It never calls the OpenAPI and never echoes secrets — only booleans.
  • Test prompt: "Check whether the HiAgent MCP server is healthy and properly configured."
  • Expected result: status="ok", auth="aksk", and configured=true with each *_configured flag true when env vars are set; no credential values are returned.

list_datasets

  • Best practice: use it to discover the DatasetIDs required by call_knowledge_engine_tool; page with page_number/page_size (1–100) instead of requesting everything at once. dataset == knowledge base.
  • Test prompt: "List the knowledge bases in workspace <workspace_id>."
  • Expected result: a paged list of datasets, each with its id and name, that you can feed into the knowledge engine.

get_dataset

  • Best practice: call it when you want a dataset's default retrieval parameters (e.g. RetrievalTopK, RetrievalScoreThreshold) so your call_knowledge_engine_tool arguments match how the base was configured.
  • Test prompt: "Show the details and default retrieval settings of dataset <dataset_id> in workspace <workspace_id>."
  • Expected result: the dataset's metadata including its default retrieval parameters.

call_knowledge_engine_tool

  • Best practice: pass 1–5 short, self-contained queries (not a whole conversation); start with a small top_k (e.g. 3) and a modest score_threshold (e.g. 0.2), then tune. Only tool_name="knowledge_search" is supported in this version.
  • Test prompt: "Search datasets [<dataset_id>] in workspace <workspace_id> for "How do I reset my password?" and return the top 3 chunks."
  • Expected result: a Result.KnowledgeSearch.Hits[] payload where each hit carries DatasetID / DocumentID / SegmentID / Content; an unsupported tool_name is rejected with a clear error, and invalid arguments (empty queries, score_threshold outside 0–1) raise a validation error.

MCP Integration

To add this server to your MCP configuration, add the following to your MCP settings file:

{
  "mcpServers": {
    "hiagent": {
      "command": "uvx",
        "args": [
          "--from",
          "git+https://github.com/volcengine/mcp-server#subdirectory=server/mcp_server_hiagent",
          "mcp-server-hiagent"
        ],
      "env": {
        "HIAGENT_TOP_HOST": "http://your-top-host:30040",
        "HIAGENT_ACCESS_KEY_ID": "your-access-key",
        "HIAGENT_SECRET_ACCESS_KEY": "your-secret-key",
        "HIAGENT_ACCOUNT_ID": "1000000000",
        "HIAGENT_REGION": "cn-north-1",
        "FASTMCP_CHECK_FOR_UPDATES": "off"
      }
    }
  }
}

This uses the STDIO transport (the default), which the HiAgent MCP plugin launches locally and injects credentials into via its environment-variable table.

Troubleshooting

Common Issues

  1. Authentication Errors

    • Verify your AK/SK credentials are correct
    • Check that you have the necessary permissions for the workspace and datasets
  2. Startup Failure in Restricted Networks

    • Set FASTMCP_CHECK_FOR_UPDATES=off to skip FastMCP's outbound update check
  3. Empty or Denied Results

    • Verify the workspace_id and dataset_ids are correct
    • Confirm HIAGENT_TOP_HOST points to the HiAgent Platform API (volc-top) gateway, not the web or Agent API address

Logging

The server uses Python's logging module with INFO level by default. You can see detailed logs in the console when running the server.

License

volcengine/mcp-server is licensed under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_server_hiagent-0.1.0.tar.gz (98.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_server_hiagent-0.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_hiagent-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_server_hiagent-0.1.0.tar.gz
  • Upload date:
  • Size: 98.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.14

File hashes

Hashes for mcp_server_hiagent-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2d98f733f4dbb2e6d8b0e4b6c25f77a564118dfa664d5d69814df0afa6abca36
MD5 ce50a7057f5d00bc27857b7aba0c502a
BLAKE2b-256 1b1d3eb9745ba0c776647a6331f7dc88dec324cba17ba39990786ca03b660fe6

See more details on using hashes here.

File details

Details for the file mcp_server_hiagent-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_hiagent-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3465a9f7d359ce2dcf0336a6d83aa3b34cf212449a23694634d008d48adb4aa9
MD5 04b7003edf459d197dc422201f13395d
BLAKE2b-256 f69995ddcd86130100b24d916c423461d5a4072ce57bd326d3358f2039e3df0f

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page