Assembling and Deploying Applications · Topic 4 of 4
MCP Servers, Memory, Prompt Versions and CI/CD
Databricks GenAI Engineer: managed, external and custom MCP servers, agent memory in Lakebase, Prompt Registry versions and aliases, and CI/CD for agents.
- 5 min
- MCP servers advertise tools and schemas; agents discover them at run time.
- Managed for Databricks resources, external for existing third party servers, custom as a Databricks App.
- Serving endpoints are stateless; conversation and long term memory need a persistent store.
What it is
A production agent needs more than a model. It reaches tools through MCP servers, keeps state between turns in a persistent datastore, loads its prompts from a versioned Prompt Registry, and moves from development to production through a tested CI/CD process.
Each of these keeps a moving part outside the agent code, so it can change, be governed and be rolled back on its own.
How it works
MCP servers
The Model Context Protocol gives agents a standard way to use tools. An MCP server lists its tools with input schemas, and the MCP client in the agent discovers them at run time, so you do not hard code each tool.
| Type | What it is | Pick it when |
|---|---|---|
| Managed | Databricks hosted servers for Vector Search indexes, Genie spaces, Unity Catalog functions and Databricks SQL | The tool is Databricks data and you want no hosting |
| External | A third party or self hosted server reached through a Unity Catalog connection | The tool already exists outside Databricks, such as a SaaS service |
| Custom | Your own MCP server hosted as a Databricks App | You need custom logic or want to wrap an internal REST API |
Managed servers are addressed by workspace URLs that name the resource, for example /api/2.0/mcp/genie/{genie_space_id}, and they enforce Unity Catalog permissions. External connections keep credentials in Unity Catalog rather than in agent code.
Persistent memory
| Memory | Holds | Store |
|---|---|---|
| Short term | The state of one conversation or thread | A session store, backed by Lakebase (managed Postgres) |
| Long term | Durable facts and preferences recalled in later conversations | A memory store, also backed by Lakebase, searched semantically |
| Structured results | Intermediate outputs other jobs read | A Delta table in Unity Catalog |
Model Serving endpoints are stateless, so memory kept in a Python variable is lost between requests and replicas. A low latency transactional store such as Lakebase fits per turn reads and writes; Delta tables fit analytical or batch reuse of results.
Prompt version control
The MLflow Prompt Registry stores prompts in Unity Catalog with a catalog.schema.prompt name. Each registration creates an immutable version; an alias is a movable pointer to one version.
p = mlflow.genai.register_prompt(
name="main.support.answer_prompt",
template="Using only the context, answer: {{question}}",
commit_message="Restrict answers to context")
mlflow.genai.set_prompt_alias(name="main.support.answer_prompt", alias="production", version=p.version)
prompt = mlflow.genai.load_prompt("prompts:/main.support.answer_prompt@production")
text = prompt.format(question="How do I reset my password?")
Because the agent loads the prompt by alias, moving production to a new version changes behavior without redeploying code, and moving it back is an instant rollback.
CI/CD for agents
- Test components on their own. Check that the retriever returns the expected chunks for known queries, that each tool returns valid output for sample arguments, and that the prompt formats correctly, before testing the whole agent.
- Gate on evaluation. Run the agent against an evaluation dataset and promote only when scorer results meet the bar.
- Promote prompts across environments by registering the approved version in the target environment and moving its alias, never by editing prompt text in production.
- Update the Vector Search index as part of the pipeline: a job writes new chunks to the source Delta table, then calls
index.sync()for a triggered Delta Sync index, or upserts for a Direct Vector Access index. - Deploy as code with Databricks Asset Bundles (called Declarative Automation Bundles in newer docs), so jobs, endpoints and permissions are defined in files and versioned in Git.
How the exam asks about this
- "The agent must query several Genie spaces and Unity Catalog functions without anyone hosting a server." Use managed MCP servers.
- "Users expect the assistant to remember their preferred region in next week's conversation." Store it as long term memory in a persistent store such as Lakebase, not in the endpoint process.
- "A prompt change hurt answer quality in production and must be reverted at once." Move the production alias back to the previous prompt version.
What to remember for the exam
- MCP servers advertise tools and schemas; agents discover them at run time.
- Managed for Databricks resources, external for existing third party servers, custom as a Databricks App.
- Serving endpoints are stateless; conversation and long term memory need a persistent store.
- Prompt versions are immutable; aliases move to promote or roll back.
- Test the retriever, tools and prompts individually, then gate releases on evaluation.
- Keep the vector index fresh with a pipeline step that syncs or upserts after new data lands.
Do not edit the production prompt in place or hard code it in the agent. Without versions and aliases you cannot tell which prompt produced an answer or roll back a bad change.
Common mistakes
Building a custom MCP server for Databricks data. Managed servers already cover Genie spaces, Vector Search and Unity Catalog functions with governance built in. Custom servers are for logic Databricks does not provide.
Keeping chat history in agent memory. Replicas scale up and down, and each request may land on a different one. History must live in a datastore every replica can read.
Testing only end to end. A bad answer could come from the retriever, a tool or the prompt. Component tests show which part broke.
Check yourself
When should you build a custom MCP server instead of using a managed one?
When the agent needs custom logic or an internal REST API that no managed server offers; you then host the server as a Databricks App.
How do you roll back a prompt change without redeploying the agent?
Point the alias the agent loads, such as production, back at the previous immutable prompt version in the Prompt Registry.
Why should chat history not be kept in a Python variable inside a served agent?
Serving endpoints are stateless and scale across replicas, so the history would be lost; it belongs in a persistent store such as Lakebase.
Topic 4 of 4 in Assembling and Deploying Applications
Test yourself on Assembling and Deploying Applications
The full Databricks Generative AI Engineer Associate question bank has 600 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Databricks. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.