MCP State Server 51941e5f

MCPAI代理

提供方 natefleming

AI代理 stdio · 本地进程 Token 社区 / 第三方
查看接入方式

一个用于持久化对话和用户偏好的MCP服务器,基于Databricks Lakehouse Postgres,适用于AI助手和其他MCP客户端。

一句话选型结论

按资料字段整理

MCP State Server 51941e5f 属于AI代理类 MCP 服务器,stdio · 本地进程,Token,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类AI代理 传输方式stdio · 本地进程 鉴权Token 部署方式本地部署
GitHub 星标 0 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

AI代理
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

适用场景

对话管理Python本地部署用户偏好AI助手数据库服务Databricks集成

安装与配置

stdio · 本地进程 Token
客户端在本机拉起子进程,数据不出本机
uv run python -c "import mcp_state_server; print('✓ Installation successful')"

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
给代理接外部能力

让代理在任务中途调用搜索、数据库等真实工具。

多步任务编排

把一串操作拆成步骤,由代理按顺序执行。

自动化重复流程

把固定流程交给代理跑,减少手工操作。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 使用前要准备好Token对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
MCP State Server 51941e5f当前 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Filesystem 560c4363 13 未标注 本地部署 无 2026-05-17
Server Everything (everything) 11 stdio · 本地进程 本地部署 有 2026-05-17
Time 7365cb6d 2 SSE · 服务端推送 远程部署 有 2026-05-18
Everything Claude Code 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Openmemory 557e1585 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

AI代理
字段来自项目仓库与公开索引,中文说明由本站标注
提供方natefleming上游标注的维护方 natefleming
分类AI代理本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式Token远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · Python本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

14.5 KB
来自项目仓库与上游目录的原文,未做删改

MCP State Server

An MCP (Model Context Protocol) server for conversation and preference persistence using Databricks Lakehouse Postgres. This server provides tools for managing conversations, messages, and user preferences that can be used by AI assistants and other MCP clients.

Table of Contents

  • MCP State Server
  • Table of Contents
  • Prerequisites
  • Step 1: Create a Databricks Service Principal
    • Option A: Using Databricks UI
    • Option B: Using Databricks CLI
  • Step 2: Create a Lakehouse Postgres Instance
    • Option A: Using Databricks UI
    • Option B: Using Databricks CLI
  • Step 3: Store Secrets in Databricks Secret Scope
    • Create a Secret Scope
    • Store Secrets
  • Step 4: Install Dependencies
    • Using uv (Recommended)
    • Using pip
  • Step 5: Configure Environment Variables
    • Create .env File
    • Edit .env File
  • Step 6: Run Locally
    • Start the Server
    • Verify Server is Running
  • Step 7: Deploy as Databricks App
    • Update databricks.yml (if needed)
    • Deploy Using Databricks Asset Bundles
    • Verify Deployment
  • Step 8: Test the Server
    • Test Health Endpoint
    • Test MCP Tools (Using MCP Client)
    • Test Using Python
  • Troubleshooting
    • Server Won't Start Locally
    • Database Connection Fails
    • App Deployment Fails
    • "Role does not exist" Error
    • Secret Scope Not Found
  • Additional Resources
  • Support

Prerequisites

Before you begin, ensure you have:

  • A Databricks workspace (Azure, AWS, or GCP)
  • Databricks CLI installed and configured (databricks --version)
  • Python 3.12 or higher (python3 --version)
  • uv package manager installed (uv --version) - Installation guide
  • Access to create service principals, databases, and secrets in your Databricks workspace

Step 1: Create a Databricks Service Principal

A service principal is a non-human identity that can be used to authenticate applications. This is required for the MCP server to authenticate with Databricks.

Option A: Using Databricks UI

  1. Log into your Databricks workspace
  2. Go to Settings → Identity and Access → Service Principals
  3. Click Add Service Principal
  4. Enter a name (e.g., mcp-state-server-sp)
  5. Click Add
  6. Important: Copy the Application ID (Client ID) - you'll need this later
  7. Click Generate Token or Add Secret to create a client secret
  8. Important: Copy the Client Secret immediately - you won't be able to see it again

Option B: Using Databricks CLI```bash

Create the service principal

databricks service-principals create \
--display-name "mcp-state-server-sp" \
--output JSON > sp_info.json

Extract the application ID (Client ID)

CLIENT_ID=$(cat sp_info.json | jq -r '.applicationId')
echo "Client ID: $CLIENT_ID"

Generate a client secret (valid for 100 days by default)

databricks service-principals create-secret \
--service-principal-id "$CLIENT_ID" \
--output JSON > sp_secret.json

Extract the secret value

CLIENT_SECRET=$(cat sp_secret.json | jq -r '.secret')
echo "Client Secret: $CLIENT_SECRET"

Save these values - you'll need them in Step 3


**Replace these values:**
- `mcp-state-server-sp` - Use your preferred service principal name
- `100` - Adjust token expiration days as needed

## Step 2: Create a Lakehouse Postgres Instance

Lakehouse Postgres is Databricks' managed PostgreSQL service. You'll create an instance to store conversation and preference data.

### Option A: Using Databricks UI

1. Log into your Databricks workspace
2. Go to **SQL** → **Lakehouse Postgres**
3. Click **Create Instance**
4. Fill in the details:
   - **Instance Name**: `mcp-state-server-pg` (or your preferred name)
   - **Capacity**: Choose based on your needs (e.g., `Small` for development)
   - **Region**: Select your preferred region
5. Click **Create**
6. Wait for the instance to be created (status will show as "Available")
7. **Important**: Note the instance name - you'll need it in Step 5

### Option B: Using Databricks CLI```bash
# Create a Lakehouse Postgres instance
databricks database-instances create \
  --instance-name "mcp-state-server-pg" \
  --capacity "SMALL" \
  --region "us-east-1" \
  --output JSON > instance_info.json

# Check instance status
INSTANCE_NAME="mcp-state-server-pg"
databricks database-instances get \
  --instance-name "$INSTANCE_NAME" \
  --output JSON | jq '.state'

# Wait until state is "AVAILABLE" (may take a few minutes)

Replace these values:
- mcp-state-server-pg - Use your preferred instance name
- SMALL - Options: SMALL, MEDIUM, LARGE, XLARGE
- us-east-1 - Use your Databricks region (e.g., westus2 for Azure, us-west-2 for AWS)

Step 3: Store Secrets in Databricks Secret Scope

Secrets are securely stored credentials that the Databricks App can access. You'll create a secret scope and store your service principal credentials.

Create a Secret Scope```bash

Create a secret scope (if it doesn't exist)

databricks secrets create-scope \
--scope "retail_consumer_goods" \
--initial-manage-principal "users"

Or use an existing scope - replace "retail_consumer_goods" with your scope name


**Replace this value:**
- `retail_consumer_goods` - Use your preferred secret scope name (must match `databricks.yml`)

### Store Secrets```bash
# Set your Databricks workspace host
# For Azure: https://adb-<workspace-id>.<deployment>.azuredatabricks.net
# For AWS: https://<workspace-id>.cloud.databricks.com
# For GCP: https://<workspace-id>.gcp.databricks.com
LAKEBASE_HOST="https://adb-1234567890123456.7.azuredatabricks.net"

# Use the Client ID and Secret from Step 1
LAKEBASE_CLIENT_ID="your-client-id-from-step-1"
LAKEBASE_CLIENT_SECRET="your-client-secret-from-step-1"

# Store the secrets
databricks secrets put \
  --scope "retail_consumer_goods" \
  --key "RETAIL_AI_DATABRICKS_HOST" \
  --string-value "$LAKEBASE_HOST"

databricks secrets put \
  --scope "retail_consumer_goods" \
  --key "RETAIL_AI_DATABRICKS_CLIENT_ID" \
  --string-value "$LAKEBASE_CLIENT_ID"

databricks secrets put \
  --scope "retail_consumer_goods" \
  --key "RETAIL_AI_DATABRICKS_CLIENT_SECRET" \
  --string-value "$LAKEBASE_CLIENT_SECRET"

# Verify secrets are stored
databricks secrets list --scope "retail_consumer_goods"

Replace these values:
- retail_consumer_goods - Must match the scope name in databricks.yml
- LAKEBASE_HOST - Your Databricks workspace URL (e.g., https://adb-1234567890123456.7.azuredatabricks.net)
- LAKEBASE_CLIENT_ID - The Application ID from Step 1 (UUID format, e.g., xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
- LAKEBASE_CLIENT_SECRET - The Client Secret from Step 1 (keep this secure - never commit to version control!)

Note: If you use a different secret scope name, update databricks.yml to match:```yaml

In databricks.yml, update these lines:

scope: retail_consumer_goods # Change to your scope name


## Step 4: Install Dependencies

Install Python dependencies using `uv` (recommended) or `pip`.

### Using uv (Recommended)```bash
# Navigate to the project directory
cd /path/to/mcp_state_server

# Install dependencies
uv sync

# Verify installation
uv run python -c "import mcp_state_server; print('✓ Installation successful')"

Using pip```bash

Navigate to the project directory

cd /path/to/mcp_state_server

Install dependencies

pip install -r requirements.txt

Verify installation

python -c "import mcp_state_server; print('✓ Installation successful')"


## Step 5: Configure Environment Variables

Create a `.env` file in the project root with your configuration.

### Create .env File```bash
# Copy the example (if it exists) or create a new file
cp .env.example .env  # If example exists
# OR
touch .env  # Create new file

Edit .env File

Open .env in a text editor and add the following:```bash

Databricks Workspace Configuration (for service principal authentication)

LAKEBASE_HOST=https://adb-1234567890123456.7.azuredatabricks.net
LAKEBASE_CLIENT_ID=your-client-id-from-step-1
LAKEBASE_CLIENT_SECRET=your-client-secret-from-step-1

Lakehouse Postgres Instance

LAKEBASE_INSTANCE_NAME=your-instance-name-from-step-2
DATABRICKS_POSTGRES_INSTANCE_NAME=your-instance-name-from-step-2

Alternative: Direct PostgreSQL Connection (for local testing)

PGHOST=localhost

PGPORT=5432

PGDATABASE=databricks_postgres

PGUSER=postgres

PGPASSWORD=your-password

Logging

LOG_LEVEL=DEBUG


**Replace these values:**
- `LAKEBASE_HOST` - Your Databricks workspace URL from Step 3 (e.g., `https://adb-1234567890123456.7.azuredatabricks.net`)
- `LAKEBASE_CLIENT_ID` - The Application ID (Client ID) from Step 1 (UUID format, e.g., `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`)
- `LAKEBASE_CLIENT_SECRET` - The Client Secret from Step 1 (keep this secure - never commit to version control!)
- `LAKEBASE_INSTANCE_NAME` - The instance name from Step 2 (e.g., `mcp-state-server-pg`)
- `DATABRICKS_POSTGRES_INSTANCE_NAME` - Same as LAKEBASE_INSTANCE_NAME

**For local testing** (optional):
- If you have a local PostgreSQL instance, uncomment and configure the `PGHOST`, `PGPORT`, etc. lines
- Set `use_databricks_auth=False` in your test configuration

## Step 6: Run Locally

Test the server locally before deploying.

### Start the Server```bash
# Using uv
uv run python main.py

# OR using the entry point
uv run mcp-state-server

# OR with custom port
uv run mcp-state-server --port 8080

# OR using python directly
python main.py --port 8000

Verify Server is Running

Open a new terminal and test the server:```bash

Check health endpoint

curl http://localhost:8000/

Expected response:

{"message":"MCP State Server is running","status":"healthy","description":"MCP server for conversation and preference persistence"}


The server should start on `http://localhost:8000` by default.

## Step 7: Deploy as Databricks App

Deploy the MCP server as a Databricks App so it can be accessed by users in your workspace.

### Update databricks.yml (if needed)

If you used a different secret scope name in Step 3, update `databricks.yml`:```yaml
# In databricks.yml, update the scope name:
scope: your-secret-scope-name  # Change from "retail_consumer_goods" if different

Deploy Using Databricks Asset Bundles```bash

Validate the bundle configuration

databricks bundle validate

Deploy the app

databricks bundle deploy \
--var lakebase_instance_name="mcp-state-server-pg"

Check deployment status

databricks apps list


**Replace this value:**
- `mcp-state-server-pg` - Your instance name from Step 2

### Verify Deployment```bash
# List deployed apps
databricks apps list

# Get app details
databricks apps get --app-name "mcp-state-server"

# Get app URL
databricks apps get --app-name "mcp-state-server" --output JSON | jq -r '.url'

The app URL will be in the format: https://mcp-state-server-..databricksapps.com

Step 8: Test the Server

Test the deployed MCP server to ensure it's working correctly.

Test Health Endpoint```bash

Replace <app-url> with your actual app URL from Step 7

APP_URL="https://mcp-state-server-1234567890123456.11.azure.databricksapps.com"

Test health endpoint

curl "$APP_URL/"

Expected response:

{"message":"MCP State Server is running","status":"healthy",...}


### Test MCP Tools (Using MCP Client)

If you have an MCP client configured:```bash
# Connect to the MCP server
# The server URL is: &lt;app-url&gt;/messages-sse

# Example using MCP CLI (if installed)
mcp connect sse &quot;$APP_URL/messages-sse&quot; \
  --auth &quot;Bearer $DATABRICKS_TOKEN&quot;

# List available tools
mcp list-tools

Test Using Python```python

import httpx
from mcp.client.sse import sse_client
from mcp import ClientSession

Replace with your app URL

app_url = "https://mcp-state-server-1234567890123456.11.azure.databricksapps.com"
sse_url = f"{app_url}/messages-sse"

Get Databricks token

import os
token = os.getenv("DATABRICKS_TOKEN") # Set this in your environment

Create auth header

auth = httpx.BasicAuth(token, "")

Connect and test

async with sse_client(sse_url, auth=auth) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()

    # List tools
    tools = await session.list_tools()
    print(f&quot;Available tools: {[t.name for t in tools.tools]}&quot;)

    # Test health tool
    result = await session.call_tool(&quot;health&quot;, arguments={})
    print(f&quot;Health check: {result.content[0].text}&quot;)

## Troubleshooting

### Server Won&#x27;t Start Locally

**Problem**: `ModuleNotFoundError` or import errors

**Solution**:```bash
# Ensure dependencies are installed
uv sync

# Or with pip
pip install -r requirements.txt

Database Connection Fails

Problem: psycopg2.OperationalError or authentication errors

Solutions:
1. Verify your .env file has correct values:bash # Check environment variables are set cat .env | grep -E &quot;(LAKEBASE|DATABRICKS|PG)&quot;

  1. Verify service principal has access:bash # Test service principal authentication databricks service-principals get --service-principal-id &quot;$CLIENT_ID&quot;

  2. Verify Lakehouse Postgres instance is available:bash databricks database-instances get \ --instance-name &quot;mcp-state-server-pg&quot; \ --output JSON | jq &#x27;.state&#x27; # Should be &quot;AVAILABLE&quot;

App Deployment Fails

Problem: Error: failed to update app or resource errors

Solutions:
1. Verify secrets exist:bash databricks secrets list --scope &quot;retail_consumer_goods&quot;

  1. Verify instance name matches:bash # Check instance exists databricks database-instances get \ --instance-name &quot;mcp-state-server-pg&quot;

  2. Check bundle validation:bash databricks bundle validate

"Role does not exist" Error

Problem: FATAL: role &quot;...&quot; does not exist

Solution: The service principal's Application ID is being used as the PostgreSQL role, which may not exist. Ensure:
- The service principal has proper permissions
- The instance allows service principal connections
- Consider using a different authentication method for local testing

Secret Scope Not Found

Problem: Error: Secret scope &#x27;retail_consumer_goods&#x27; not found

Solution:
1. Create the secret scope (see Step 3)
2. Or update databricks.yml to use an existing scope name

Additional Resources

  • Databricks Lakehouse Postgres Documentation
  • Databricks Service Principals Guide
  • Databricks Apps Documentation
  • MCP Protocol Specification

Support

For issues or questions:
1. Check the Troubleshooting section
2. Review Databricks documentation links above
3. Check server logs: LOG_LEVEL=DEBUG in .env for detailed logging

常见问题

7 问
答案由本站依据条目字段整理,不引用上游原文
MCP State Server 51941e5f 怎么安装?

在客户端按下面的安装命令接入:uv run python -c "import mcp_state_server; print('✓ Installation successful')"。装完在客户端配置里引用同一个包或端点。

MCP State Server 51941e5f 怎么在客户端里配置?

它的传输方式未标注,在客户端 MCP 配置里按官方文档填写启动命令和参数,保存后重启客户端生效。

MCP State Server 51941e5f 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP State Server 51941e5f 需要 API Key 吗?

资料标注需要Token认证,使用前准备好对应凭据,并按最小权限配置。

MCP State Server 51941e5f 能提供哪些能力?

资料显示能力标签包括 对话管理、数据库服务、Python。具体工具清单以官方文档为准。

MCP State Server 51941e5f 需要什么运行环境?

运行时为 Python;属于本地进程,需要在本机装好运行环境。

MCP State Server 51941e5f 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。