opencode-hello-mcp
by uchiha-vivek
README.md
# opencode-mcp-lab
Learning MCP (Model Context Protocol) by building my own servers and using them with opencode + DeepSeek.
## Servers
| Server | What it does |
|---|---|
| `opencode-hello-mcp` | One tool, `greet-tool`: the "hello world" of MCP |
## Setup
```bash
npm install
```
## Test a server without AI (free)
```bash
npm run inspect
```
## Use it in opencode
```bash
opencode
```
Then ask: `greet Vivek using the greet tool`
## Connecting & disconnecting MCP servers
MCP servers are wired up in `opencode.json` (project root). opencode reads it on startup, so **restart opencode after any change** (`/exit`, then `opencode`).
### Connect a server
Add an entry under `"mcp"` with `"enabled": true`:
```json
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"opencode-hello-mcp": {
"type": "local",
"command": ["node", "servers/hello-mcp/index.ts"],
"enabled": true
}
}
}
```
- `"opencode-hello-mcp"`: the name opencode shows (tools appear as `opencode-hello-mcp_greet-tool`)
- `"type": "local"`: opencode starts the server on your machine
- `"command"`: how to start it (run from the project root)
### Check it's connected
```bash
opencode mcp list
```
Or inside opencode: the status bar shows `1 MCP`, and `/status` shows whether each server is connected.
### Disconnect: 3 ways
**1. Turn it off temporarily (recommended)**: set `"enabled": false` in `opencode.json` and restart opencode:
```json
"opencode-hello-mcp": {
"type": "local",
"command": ["node", "servers/hello-mcp/index.ts"],
"enabled": false
}
```
Set it back to `true` to reconnect.
**2. Toggle it for this session only**: inside opencode, type `/mcps` and switch servers on or off. No file changes; resets next time you start opencode.
**3. Remove it completely**: delete the whole `"opencode-hello-mcp": { ... }` block from `opencode.json` and restart opencode.
> Disconnecting never deletes your server code. `servers/hello-mcp/index.ts` stays, so you can reconnect anytime.
### Why disconnect?
Every connected server's tool descriptions are sent to the AI with **every message**, which costs tokens. Keep only the servers you're using switched on.This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo issues