Skip to main content

hive-metastore-mcp

A read-only Model Context Protocol server for the Apache Hive Metastore (HMS), the catalog behind Spark, Trino, Hive, Impala and Flink.

It talks to the metastore directly over its Thrift API, so it needs no HiveServer2, no query engine and no SQL. Your MCP client can browse databases, tables and partitions, read statistics, search for tables by name or column, and run diagnose_table. That tool explains the problems that usually make a table slow or unreadable: too many partitions, missing or stale statistics, small files, mismatched SerDes, and Iceberg tables whose metadata pointer looks wrong.

Install

uvx hive-metastore-mcp --help        # run without installing
pip install hive-metastore-mcp       # or install it

Python 3.10 or newer. The only runtime dependencies are the mcp SDK and the thrift runtime; the metastore bindings ship with the package.

Configure

Variable Default Meaning
HMS_URI thrift://localhost:9083 Metastore URI. A comma-separated list (as in hive.metastore.uris) is tried in order.
HMS_TIMEOUT 30 Connect and read timeout, in seconds.
HMS_TRANSPORT buffered framed if the metastore sets hive.metastore.thrift.framed.transport.enabled.
HMS_PROTOCOL binary compact if the metastore sets hive.metastore.thrift.compact.protocol.enabled.
HMS_CATALOG metastore default Catalog used when a call does not name one (Hive 3+).
HMS_MAX_RESULTS 1000 Ceiling on any list a tool returns.
HMS_MAX_PARTITION_NAMES 100000 Most partition names loaded at once (to find the newest partitions or page deep).

Command-line flags: --transport stdio|streamable-http (default stdio), --host and --port for HTTP (default 127.0.0.1:8000, path /mcp), --uri and --timeout to override the environment, and --log-level. Logs go to stderr.

Client configuration

Most MCP clients take a JSON block like this one:

{
  "mcpServers": {
    "hive-metastore": {
      "command": "uvx",
      "args": ["hive-metastore-mcp"],
      "env": { "HMS_URI": "thrift://metastore.example.com:9083" }
    }
  }
}

VS Code (.vscode/mcp.json):

{
  "servers": {
    "hive-metastore": {
      "type": "stdio",
      "command": "uvx",
      "args": ["hive-metastore-mcp"],
      "env": { "HMS_URI": "thrift://metastore.example.com:9083" }
    }
  }
}

Cursor reads the mcpServers form above from ~/.cursor/mcp.json. For a client that connects over HTTP, start hive-metastore-mcp --transport streamable-http and point it at http://127.0.0.1:8000/mcp.

Tools

Every tool is read-only and annotated readOnlyHint: true, destructiveHint: false, idempotentHint: true.

Tool What it returns
get_metastore_info Server version, catalogs, database count, this server's settings. A connection check.
list_catalogs Catalogs with descriptions and locations (Hive 3+).
list_databases Database names matching a pattern.
get_database Location, managed location, owner, parameters, data connector (Hive 4 remote databases).
list_tables Tables with type and comment, filtered by pattern and table type.
get_table Columns, partition keys, location, InputFormat/OutputFormat/SerDe, parameters, basic stats, view text, and the detected format (Iceberg, Delta, Hudi or plain Hive) with the evidence for it.
list_partitions A page of partitions in name order, optionally filtered (ds >= "2024-01-01"), with next_offset.
get_partition One partition: values, storage, every parameter, statistics, and its schema if it differs from the table's.
get_partition_stats Partition count and the newest partitions with files, bytes, rows and average file size.
get_table_statistics Table statistics and accuracy flags, plus per-column statistics (nulls, distinct values, min/max, lengths).
list_functions Permanent UDFs with class names and resource URIs, in one database or all.
get_table_lineage_lite Where the data lives and how it is written: storage root, format, Iceberg metadata file, engines that wrote it, where partitions live, and the tables a view reads.
find_tables Tables across databases by table name, column name, or both. Column searches open at most max_tables_scanned tables.
diagnose_table Findings ordered critical, warning, info; see below.

Patterns use the metastore syntax: * matches anything and | separates alternatives (sales*|finance*). In find_tables a plain word matches as a substring.

What diagnose_table checks

Code Severity When
TOO_MANY_PARTITIONS warning at 10,000, critical at 100,000 Planning and unfiltered queries will be slow.
NO_PARTITIONS info Partitioned but nothing registered (MSCK REPAIR may be needed).
STATS_MISSING, PARTITION_STATS_MISSING warning No row count (Hive or Spark statistics).
STATS_INACCURATE, PARTITION_STATS_INACCURATE warning COLUMN_STATS_ACCURATE says the basic stats are out of date.
STATS_STALE warning Zero rows recorded but data files present.
COLUMN_STATS_MISSING, COLUMN_STATS_PARTIAL, COLUMN_STATS_STALE warning / info No column stats, some columns without, or stats computed more than 7 days before the last DDL.
SMALL_FILES warning; critical for 1,000+ files under 1 MiB Average file size under 32 MiB across 10+ files (table or sampled partitions), from numFiles/totalSize.
EMPTY_PARTITIONS info Sampled partitions with numFiles=0.
FORMAT_SERDE_MISMATCH, PARTITION_FORMAT_SERDE_MISMATCH critical InputFormat, OutputFormat and SerDe disagree (e.g. Parquet files read with LazySimpleSerDe).
PARTITION_FORMATS_DIFFER info Partitions stored in another format than the table.
EXTERNAL_TABLE, MANAGED_TABLE, TRANSLATED_TO_EXTERNAL info What DROP does, ACID status, and Hive 4's managed-to-external translation.
TABLE_TYPE_INCONSISTENT warning MANAGED_TABLE with EXTERNAL=TRUE.
NO_LOCATION, MANAGED_OUTSIDE_DATABASE, PARTITIONS_OUTSIDE_TABLE_LOCATION warning / info Location oddities.
ICEBERG_NO_METADATA_LOCATION critical No engine can load the table.
ICEBERG_METADATA_OUTSIDE_LOCATION, ICEBERG_LOCATION_SCHEME_MISMATCH, ICEBERG_METADATA_LOCATION_SUSPICIOUS, ICEBERG_METADATA_NOT_ADVANCING, ICEBERG_HIVE_PARTITION_KEYS warning metadata_location not under the table, on a different URI scheme, not a .metadata.json, equal to the previous pointer, or Hive partition keys on an Iceberg table.
ICEBERG_NO_STORAGE_HANDLER, DELTA_TABLE, HUDI_TABLE, SPARK_PLACEHOLDER_SCHEMA info Where the real metadata lives.

Partitioned tables are checked on a sample of the newest partitions (partition_sample, default 100). Partition names sort as strings, so "newest" holds for date-like keys such as ds=2024-01-31.

Safety model

  • Read-only. Tools only issue metastore read calls (get_* methods). There are no write tools, and no code path a tool can reach calls a Thrift method that changes state. The live test fixture is the only code in the repository that writes, and it only runs against the throwaway test metastore.
  • Bounded output. Every list has a limit capped by HMS_MAX_RESULTS, and responses say when they were truncated. Long parameter values and view text are shortened. Partition listings page with offset, and column searches stop after max_tables_scanned tables.
  • No credentials. The plain Thrift protocol carries none, and the server refuses an HMS_URI with user info rather than logging it. Logs contain host and port only.
  • Short connections. Each tool call opens its own connection and closes it, so calls are independent and a metastore restart is harmless.
  • The metastore's own authorisation still applies. Anything the metastore lets an unauthenticated Thrift client read, this server can read. Expose it only to clients that may see the whole catalog.

Compatibility

The bindings are generated from the Hive 4.2.1 IDL. Thrift skips fields one side does not know, and the server only calls methods Hive 3 already had, so older metastores work too.

Metastore Status
Hive 4.2.1 (apache/hive:4.2.1) Live-tested
Hive 4.0.1 (apache/hive:4.0.1) Live-tested
Hive 3.1.3 (apache/hive:3.1.3) Live-tested
Hive 2.3 Untested; catalog tools fail with a clear "older than Hive 3" error
Binary or compact protocol, buffered or framed transport, no auth Supported
SASL / Kerberos, TLS Not yet (see below)

Spark, Trino, Impala and Flink share the same metastore service, so the same versions apply whichever engine owns the tables.

Not in v0.1

  • Write tools (create, alter, drop). Out of scope on purpose.
  • Kerberos (SASL/GSSAPI) and TLS. Both need extra system libraries or certificate handling; they are planned behind an optional extra.
  • AWS Glue and other HMS-compatible catalogs with their own APIs.
  • Reading Iceberg, Delta or Hudi metadata files from storage. The server reports what the metastore knows and where the real metadata lives.

Development

uv sync
uv run pytest                          # unit tests; live tests skip
uv run ruff check . && uv run ruff format --check .
scripts/live_test.sh 3.1.3 4.0.1 4.2.1 # live tests in Docker on port 19083

scripts/generate_thrift.sh regenerates src/hive_metastore_mcp/thrift_gen from the IDL in thrift/. See CONTRIBUTING.md.

License

Apache-2.0. The vendored Thrift IDL and the code generated from it come from Apache Hive and Apache Thrift; see NOTICE. This project is not affiliated with the Apache Software Foundation.

Metadata

Release files for hive-metastore-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hive-metastore-mcp 0.1.0
File Size Uploaded Provenance Actions
hive_metastore_mcp-0.1.0.tar.gz 243.1 kB With provenance Details for hive_metastore_mcp-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hive-metastore-mcp 0.1.0
File Interpreter ABI Platform Actions
hive_metastore_mcp-0.1.0-py3-none-any.whl Python 3 none any Details for hive_metastore_mcp-0.1.0-py3-none-any.whl

Total release size: 457.4 kB

Release files / hive_metastore_mcp-0.1.0.tar.gz

Download URL hive_metastore_mcp-0.1.0.tar.gz
Size 243.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b9080d01c75dc5a2235adea6071a832419163854dd7312235e474b266767121c
BLAKE2b-256 checksum
How to use checksums
ef1b89f360dfabdff699e13b05eec96b9faa8c67ffe465ed91c41f422fa0a5a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Release files / hive_metastore_mcp-0.1.0-py3-none-any.whl

Download URL hive_metastore_mcp-0.1.0-py3-none-any.whl
Size 214.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba135376ddea6849f82bf3c11bf2cb865687e4f3cc1dc6711f003964b7c745e8
BLAKE2b-256 checksum
How to use checksums
b9d83d53b994dcff5d4ec0bf5d87dad96b5893e6c24f04b31c1ab5d0caed3cf1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

Security for hive-metastore-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hive_metastore_mcp-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page