# Dify integration with TiDB Vector, Data Service, and MCP

Apply this topic when a ticket asks whether or how Dify can use TiDB or TiDB
Cloud. Treat the following as three materially different integration paths;
do not reduce the answer to only a query API and MCP.

## Native TiDB Vector backend for Dify Knowledge Pipeline

Dify's self-hosted deployment supports TiDB Vector as the vector store used by
its Knowledge Pipeline. Configure both the Dify `api` and `worker` services
with:

```yaml
VECTOR_STORE: tidb_vector
TIDB_VECTOR_HOST: <host>
TIDB_VECTOR_PORT: 4000
TIDB_VECTOR_USER: <user>
TIDB_VECTOR_PASSWORD: <password>
TIDB_VECTOR_DATABASE: <database>
```

This path stores Dify knowledge chunks, metadata, and embeddings in TiDB and
retrieves them through Dify's Knowledge node. It is a native vector-store
backend, not a Data Service query Endpoint and not an MCP connection.

For TiDB Cloud Dedicated, lead with this path when the applicable customer
context says Dedicated. TiDB Vector Search is available on Dedicated for TiDB
v8.4.0 or later, with v8.5.0 or later recommended. A vector search index
requires TiFlash. Confirm the target cluster's exact version and Vector Search
availability before promising that this configuration can be enabled there.
When the ticket omits those facts, the customer reply must still give the
Dedicated path first and then end with one focused question confirming that the
target is a Dedicated cluster on TiDB v8.4.0 or later and, if a vector index is
required, that TiFlash is deployed. A conditional version sentence alone does
not satisfy this confirmation. Set `decision=human_required`,
`clarificationSimulation.required=true`, and use the smallest applicable
`requestedContext` for that customer-owned discriminator.

Source: [Dify x TiDB: distributed vector storage](https://dify.ai/blog/dify-x-tidb-supercharge-your-knowledge-pipeline-with-distributed-vector-storage)
and [TiDB Vector Search Index](https://docs.pingcap.com/tidb/stable/vector-search-index/).

## Query API / OpenAPI tool

TiDB Cloud Data Service can expose a bounded query Endpoint and an OpenAPI
configuration that Dify imports as a tool. This path is appropriate when Dify
needs to call a business query API; it does not make TiDB Dify's knowledge-base
vector store. Preserve the Data Service service-tier and preview limitations
from the current official documentation.

Source: [Integrate a Data App with third-party tools](https://docs.pingcap.com/tidbcloud/data-service-integrations/).

## MCP

The TiDB MCP Server is open source and must be deployed and connected to the
database separately. Do not describe it as a TiDB Cloud hosted MCP Endpoint.
Dify can use it only through a compatible MCP client/plugin and transport.

Source: [TiDB MCP Server](https://docs.pingcap.com/tidb/stable/tidb-mcp-server/).

For production use, keep database and API credentials least-privileged and
prefer read-only access for query or retrieval workloads. Never expose internal
customer segmentation or credentials in the customer reply.
