Connect a read-only MCP server to a coding assistant
Connect a small read-only MCP context source in an optional lab and explain its trust, credentials, capability scope and audit trail.
By Invicly Tech, , in Prompt Engineering and Vibe Coding. About 10 minutes to read.
In short
The Model Context Protocol (MCP) is an open standard that lets an assistant talk to outside tools and data through small programs called servers. A server can expose tools, resources and prompts. Connect only servers you trust, give them read-only credentials, and keep a record of what they were asked to do.
Think of it like this: An MCP server is like a library desk: you may ask for one book at a time, and the desk keeps a log, but you would not hand it the keys to the whole building.
Explained simply
An assistant on its own only knows what is in its training and in the files you show it. Often you want it to look something up: a page in your docs, a row in a test database, a ticket. The Model Context Protocol, or MCP, is a common way to plug such sources into an assistant.
There are three roles. The host is the app you use, like your editor. Inside it, a client holds a connection to one server. The server is a small program that offers things the assistant can use: tools to run, resources to read and ready-made prompts.
Because a server can act for the assistant, you must decide whether to trust it. A local server runs code on your computer. A remote server receives whatever the assistant sends it. Start with a server you wrote yourself or one from a source you can check.
Then keep its power small. Give it a read-only credential, turn on only the tools you need, and keep a log of the calls it made. If something goes wrong, the log tells you what happened.
Press Play on a diagram to walk through it one step at a time.
- 1Host
The app you use, such as your editor with its assistant
- 2Client
Part of the host that keeps one connection to one server
- 3Server
A program that exposes tools, resources and prompts
- 4Data or service
A database, docs folder or API behind the server
- 1Pick
Choose a server from a source you trust
- 2Read
List its tools and what each one can do
- 3Scope
Give it a read-only credential
- 4Test
Try one harmless read on fake data
- 5Audit
Review the tool call log
- Tools
- search_docs (read)
- get_page (read)
- Resources
- docs://index
- docs://changelog
- Left off
- write_page
- delete_page
In depth
Hosts, clients and servers
In the MCP design, the host is the application that contains the assistant. For each server it connects to, the host creates a client. That client holds a dedicated connection to that single server. So three servers means three clients inside one host.
A server can offer three kinds of thing. Tools are actions the model decides to call, such as search_docs. Resources are data the host can read, such as a file. Prompts are templates you choose to run. Servers talk to clients using a standard message format, over a local process connection (stdio) or over HTTP for remote servers.
- Host contains the assistant
- One client per server
- Tools, resources and prompts
- stdio for local, HTTP for remote
- Assistant to MCP client: Wants to look up a doc1Wants to look up a doc
- MCP client to MCP server: Asks which tools exist2Asks which tools exist
- MCP server to MCP client: Lists search_docs (read-only)3Lists search_docs (read-only)
- MCP client to MCP server: Calls search_docs with a query4Calls search_docs with a query
- MCP server to MCP client: Returns matching text5Returns matching text
- MCP client to Assistant: Passes the text in as data6Passes the text in as data
Adding a server in your editor
Editors that support MCP, VS Code among them, let you add servers through a settings command or a configuration file. In VS Code a workspace file named .vscode/mcp.json holds a servers section. Each entry gives a name, how to start it and any settings. Check the current VS Code documentation for the exact format, because it changes between releases.
When you add a server, the editor shows the tools it offers. Read that list. Many tools ask for your approval before first use. Prefer a server limited to one job, such as reading a docs folder. Never put real tokens in a file you commit; use the input or environment features your editor offers.
- Workspace file or user settings
- Read the tool list before enabling
- Approve tools one at a time
- Keep tokens out of committed files
Scope credentials and capabilities
A server can only do what its credentials allow. If you give a database server an admin account, a mistake can drop tables. If you give it a user that can only run SELECT on a test database, the worst case is a wasted query.
Apply the same idea to capabilities. If a server offers both read and write tools, turn off the write tools. Limit its folder or repository scope. Use tokens that expire. The MCP security best practices guide warns about risks such as tokens passed to the wrong service and servers that run more than the user expects.
- Admin database account
- All tools enabled
- Long-lived token in the repo
- No log kept
- SELECT-only test user
- Only read tools enabled
- Short-lived token from the environment
- Tool calls logged
Trust and audit
Decide who you trust before you connect. Prefer servers from the maintainer of the product you are using or from your own team. Look at the source if it is open. Check how it is updated, because a local server that updates itself can change what it does without you noticing.
Keep an audit trail: which tool was called, with what input, at what time and by which session. Your editor's output panel may show it, and your server can write its own log. When you review the log, look for calls you did not expect and for data going to places you did not choose.
- Prefer known maintainers
- Read the source if you can
- Watch for silent updates
- Log tool, input, time and session
Learn it in 5 short steps
About 35m each. Track them with a timer in your plan.
- 1Explain MCP hosts, clients and servers~35m
- 2Add a read-only server in VS Code~35m
- 3Scope credentials and capabilities~35m
- 4Decide which servers to trust~35m
- 5Keep an audit trail of tool calls~35m
Key points
- A host runs one client per server. The server offers tools the model can call, resources it can read and prompts you can pick.
- A server may run locally, started by your editor, or remotely over HTTP. A local server runs code on your machine, so trust matters.
- Give the server the smallest credential: a read-only database user, a token limited to one repository.
- Read the tool list before you enable a server. Disable any tool that writes, deletes or sends.
- Tool calls should be visible. Keep the log so you can say who asked what, and when.
Key terms
Tap a card to flip it. 0/5 known
Examples
{
"servers": {
"docs-reader": {
"type": "stdio",
"command": "node",
"args": ["./tools/docs-reader.js"],
"env": { "DOCS_DIR": "./docs" }
}
}
}A VS Code style .vscode/mcp.json for a local server you wrote or reviewed. The names are placeholders.
A read-only docs lab
Prerequisite: an editor with MCP support and a folder of fake Markdown docs. Step 1: write or obtain a small server that exposes only search_docs and get_page for that folder. Step 2: add it to the workspace config. Step 3: ask the assistant a question that the docs answer. Evidence: the tool call appears in the log with your query. Rollback: remove the entry from the config and delete the server file. No paid service is needed.
{
"servers": {
"docs-reader": {
"type": "stdio",
"command": "node",
"args": ["./tools/docs-reader.js"],
"env": { "DOCS_DIR": "./fake-docs" }
}
}
}Giving a database server a read-only user
You want an assistant to answer questions about a local test database. Step 1: create a Postgres role that can only SELECT. Step 2: point the server at that role, not at your admin login. Step 3: ask a read question and confirm it works. Step 4: ask it to delete a row and confirm the database refuses. Cleanup: drop the role and the test database afterwards.
CREATE ROLE mcp_reader LOGIN PASSWORD '<password>';
GRANT CONNECT ON DATABASE app_dev TO mcp_reader;
GRANT USAGE ON SCHEMA public TO mcp_reader;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO mcp_reader;
-- cleanup
DROP OWNED BY mcp_reader;
DROP ROLE mcp_reader;Quick reference
- Host runs the assistant, a client connects to one server.
- Servers offer tools, resources and prompts.
- Local servers run code on your machine, so trust them first.
- Give servers read-only credentials and disable write tools.
- Keep tokens out of committed config files.
- Log every tool call: tool, input, time, session.
Common mistakes
- Installing a server from a random post and running it with your own full-access credentials.
- Enabling every tool a server offers when you only need one read tool.
- Pasting a real token into the config file and committing it.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Draw the host, client and server for a setup with two servers. How many clients are there?
- Exercise 2medium
Write a trust checklist of five questions to answer before you add any MCP server.
- Exercise 3hard
Run the read-only docs lab with a folder of fake docs. Capture the tool call log, then add a write tool, confirm you disabled it, and remove everything.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Is MCP only for one company's assistant?
- No. It is an open protocol, and several editors and assistants support it. Check your tool's documentation for the version and features it supports.
- Do I need to pay for an MCP server?
- Not for a local lab. You can write a tiny server yourself or use a free local one. Some hosted services have their own pricing.
- Is a read-only server completely safe?
- No. It can still return sensitive data or text that tries to steer the assistant. Limit what it can read and treat its output as untrusted.