Skip to content

docs: Database access MCP#54409

Closed
gabrielcorado wants to merge 2 commits intomasterfrom
gabrielcorado/mcp-dbs-docs
Closed

docs: Database access MCP#54409
gabrielcorado wants to merge 2 commits intomasterfrom
gabrielcorado/mcp-dbs-docs

Conversation

@gabrielcorado
Copy link
Copy Markdown
Contributor

Initial documentation for Model Context Protocol (MCP) for database access feature.

Note: The "Troubleshooting" section is still pending.

@gabrielcorado gabrielcorado added documentation no-changelog Indicates that a PR does not require a changelog entry labels Apr 30, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 30, 2025

Amplify deployment status

Branch Commit Job ID Status Preview Updated (UTC)
gabrielcorado/mcp-dbs-docs HEAD 1 ✅SUCCEED gabrielcorado-mcp-dbs-docs 2025-04-30 12:03:33

Comment on lines +52 to +53
`tsh mcp db` command directly starts a MCP server using the
[Standard Input/Output (stdio)](https://modelcontextprotocol.io/docs/concepts/transports#standard-input%2Foutput-stdio).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`tsh mcp db` command directly starts a MCP server using the
[Standard Input/Output (stdio)](https://modelcontextprotocol.io/docs/concepts/transports#standard-input%2Foutput-stdio).
`tsh mcp db` command directly starts a MCP server using the
[Standard Input/Output (stdio)](https://modelcontextprotocol.io/docs/concepts/transports#standard-input%2Foutput-stdio) transport.

Comment on lines +55 to +62
Similarly to `tsh db connect`, the database access MCP server command requires
you to pick the database user and name the MCP connections will use. In
addition, you can also filter which database will be available as an MCP
resource, either using `--query` or `--labels` flags.

As for the current version, **you can only specify a single value for
`--db-user` and `--db-name`**. All selected databases must have a database and
a database user. Otherwise, the queries will fail.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comparison to tsh db connect suggests you can expose just single database, but I guess you can do multiple, hence the restriction on single user and database name? In any case I'd rephrase to clarify this point and show how it follows from the extra flexibility.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hence the restriction on single user and database name?

We'll definitely improve this right after the first release. From my testing, having the model pick up the database user felt like a disaster that could happen anytime (and was insecure, especially with powerful users).

We'll probably have to develop a more robust solution (maybe adding options to roles), but we can discuss that in more depth when the time comes.

Comment on lines +65 to +68
Given that language models can perform any query on your database, we
recommend that you select a database user with only the permissions you want
to allow the language models to perform. Creating a user with read-only
permissions will prevent accidental changes to your database.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I thought we will do the read-only transaction trick; perhaps we can support it with a flag?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A read-only transaction is not the solution here (as we and pgx are not doing proper input validation). The models (and users) can bypass it. So we're instead enforcing the user's selection (by CLI flags) and adding this tip/warning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the bypass?

Comment on lines +9 to +15
capabilities. This guide will show you how to use the Teleport Model Context
Protocols (MCP) servers.

## Database Access for MCP

Teleport supports serving database access as MCP servers for **PostgreSQL**
databases.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a succinct answer to the question "why would I use tsh mcp db" should be a part of the intro section.

Also, we might suggest we are open for adding support for other protocols?

Comment on lines +126 to +127
After updating your MCP client configuration, you can use the Teleport
databases. Each database protocol will have its own tool to execute queries.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add example listing of tools here, to illustrate the point of multiple tools.

Comment on lines +128 to +129
Given that you might have multiple databases from the same protocol, the tool
call must specify which Teleport database it will perform the query against.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't quite understand this sentence, can you elaborate on this issue?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to clarify the usage here. If you have multiple databases of the same protocol (say PostgreSQL), you must somehow indicate to the MCP client which one to use (either by text or by attaching the resource). Otherwise, it will just pick a random one.

Copy link
Copy Markdown
Contributor

@Tener Tener May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. Perhaps changing the sentence order for clarity?

The tool call must specify which Teleport database to query, since you might have multiple databases using the same protocol.

Or longer, if you prefer it:

To avoid ambiguity, the tool call must specify which Teleport database to query, as multiple databases using the same protocol may be in scope.

Comment on lines +131 to +135
The Teleport database resources can be retrieved automatically by the clients
(using the available tool) and are also available as MCP resources. Depending
on which client you're using, you can set the target database beforehand. For
example, on Claude Desktop, you can attach the resource to the conversation and
ask the model to perform the queries on the attached database.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so we support both tools and resources? How would that work?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could still attach the resource to the conversation, and the models will use it. If you don't attach or want to let the model search/select the appropriate database instance to execute the query, it can list them and have their information available.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds great. What would you say about adding examples of both usage patterns?

After updating the configuration, you must restart the Claude Desktop app before
using the newly added MCPs.

### Step 2/2. Usage
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding real-life usage example would be super helpful.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's give a screenshot or two to illustrate the actual usage e.g. with Claude Desktop.

Comment on lines +137 to +139
### Troubleshooting

TODO
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scenarios/tasks to consider:

  1. Expired session
  2. Invalid database user, database name
  3. Some other error cases?
  4. How do you get the logs?

Copy link
Copy Markdown
Collaborator

@r0mant r0mant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, left some feedback.

Comment thread docs/pages/connect-your-client/mcp.mdx Outdated
Comment on lines +34 to +36
- The Teleport Database Service configured to access a database. See one of our
[guides](../enroll-resources/database-access/guides/guides.mdx) for how to set
up the Teleport Database Service for your database.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should specifically refer to a Postgres guide right? That's the only one we currently support via MCP.


### Step 1/2. Installation

`tsh mcp db` command directly starts a MCP server using the
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`tsh mcp db` command directly starts a MCP server using the
`tsh mcp db` command starts a local MCP server using the

Comment thread docs/pages/connect-your-client/mcp.mdx Outdated
resource, either using `--query` or `--labels` flags.

As for the current version, **you can only specify a single value for
`--db-user` and `--db-name`**. All selected databases must have a database and
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All selected databases must have a database and a database user.

What does this mean? I would expand on this here.

}
```

#### Claude Desktop
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't we plan on having a tsh command to update it? Or did we push it out of the initial scope.

E.g. tsh mcp db login xxx (and this is where another subcommand for tsh mcp db comes handy from my comment on your other PR).

Comment thread docs/pages/connect-your-client/mcp.mdx Outdated
After updating the configuration, you must restart the Claude Desktop app before
using the newly added MCPs.

### Step 2/2. Usage
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah let's give a screenshot or two to illustrate the actual usage e.g. with Claude Desktop.

`--db-user` and `--db-name`**. All selected databases must have a database and
a database user. Otherwise, the queries will fail.

<Admonition type="note" title="Permissions">
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like we should move this out of admonition and into a separate Security section that explains do's and don't's. For example, permissions considerations, explicitly state that LLM will have access to the database permitted by Teleport role, the fact that it can still run any queries it will deem necessary, etc.

Comment thread docs/sidebar.json
Comment on lines +148 to +152
{
"type": "doc",
"label": "Using Model Context Protocol (MCP)",
"id": "connect-your-client/mcp"
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a separate top-level section for MCP to increase visibility? It will be also easier to group all things MCP related under it as well.

We can keep this link here as well because it does make sense to have it under clients too, but I would have it link to the guide under main MCP section.

Co-authored-by: Roman Tkachenko <roman@goteleport.com>
@r0mant
Copy link
Copy Markdown
Collaborator

r0mant commented Jul 7, 2025

@gabrielcorado What's the status of this PR? Can it be taken out of draft?

@gabrielcorado
Copy link
Copy Markdown
Contributor Author

@r0mant The database access MCP flow changed (with the config command), so this requires some work. I'll update it and make it ready for review.

@gabrielcorado
Copy link
Copy Markdown
Contributor Author

Closing this in favor of #56828. Most of the comments here are either no longer applicable or have been addressed in the new branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation no-changelog Indicates that a PR does not require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants