# MCP protocol guide, Generative AI Community, how t

> Source: <https://promptcube3.com/en/threads/6203/>
> Published: 2026-08-13 17:24:46+00:00

# MCP protocol guide, Generative AI Community, how t

[Claude](/en/tags/claude/)to Read Local SQLite Data

Most people treat Claude like a chat box. They copy-paste code, get a fix, and paste it back. It's tedious. The real power comes when the LLM can actually reach out and touch your data. That's where the Model Context Protocol ([MCP](/en/tags/mcp/)) comes in. It's basically a standardized way to give Claude "skills" by letting it call tools on your local machine or a remote server.

I spent last Friday afternoon fighting with a local SQLite database and realized I was wasting ten minutes every hour exporting CSVs just so Claude could analyze my schema. I decided to build a small MCP server to stop the madness.

## The architecture of an MCP server

MCP works on a client-server model. Claude (the client) connects to an MCP server via stdio or HTTP. The server tells Claude, "Hey, I have these tools available," and Claude decides when to call them based on your prompt.

If you're using the Claude Desktop app, you configure these servers in a JSON file. The app spawns the server as a child process.

| Component | Role | Example |

| :--- | :--- | :--- |

| Client | The LLM Interface | Claude Desktop |

| Server | The Logic Provider | A Node.js or Python script |

| Transport | The Communication Pipe | stdio (standard input/output) |

| Tool | The Executable Action | `query_database(sql)`

|

## Setting up the environment

You'll need Node.js installed. I'm using v20.11.0. We'll use the official MCP SDK because writing the JSON-RPC layer by hand is a nightmare you don't want.

Run this in your terminal to start a fresh project:

```
mkdir claude-sqlite-mcp
cd claude-sqlite-mcp
npm init -y
npm install @modelcontextprotocol/sdk sqlite3
npm install -D typescript @types/node
npx tsc --init
```

## Coding the SQLite tool

Here is the actual implementation. This script creates a server that exposes one tool: `query_db`

. It takes a SQL string, runs it against a local file, and returns the result.

Create a file named `index.ts`

:

``` js
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
import sqlite3 from "sqlite3";
import { promisify } from "util";

const db = new sqlite3.Database("./my_data.db");
const dbAll = promisify(db.all).bind(db);

const server = new Server({
  name: "sqlite-explorer",
  version: "1.0.0",
}, {
  capabilities: {
    tools: {},
  },
});

// Tell Claude what this server can actually do
server.setRequestHandler(ListToolsRequestSchema, async () => ({
  tools: [{
    name: "query_db",
    description: "Execute a read-only SQL query on the local SQLite database",
    inputSchema: {
      type: "object",
      properties: {
        sql: { type: "string", description: "The SQL query to run" },
      },
      required: ["sql"],
    },
  }],
}));

// Handle the actual tool execution
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name !== "query_db") {
    throw new Error("Tool not found");
  }

  const sql = request.params.arguments?.sql as string;
  
  try {
    const results = await dbAll(sql);
    return {
      content: [{ type: "text", text: JSON.stringify(results) }],
    };
  } catch (err: any) {
    return {
      content: [{ type: "text", text: `Error: ${err.message}` }],
    };
  }
});

async function main() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
}

main().catch(console.error);
```

Build it:

```
npx tsc
```

## Wiring it into Claude Desktop

This is where most people trip up. Claude doesn't just "find" your server. You have to tell it where the executable is.

Open your Claude Desktop config file.

- macOS:
`~/Library/Application Support/Claude/claude_desktop_config.json`

- Windows:
`%APPDATA%\Claude\claude_desktop_config.json`

Add your server configuration:

```
{
  "mcpServers": {
    "my-sqlite-server": {
      "command": "node",
      "args": ["/absolute/path/to/your/claude-sqlite-mcp/index.js"]
    }
  }
}
```

Restart Claude Desktop completely. If you see a small hammer icon in the input box, you've won.

## Testing the connection

Try asking Claude: "What are the first 5 rows in my users table?"

Claude will now:

1. Recognize the intent.

2. Call the `query_db`

tool with `SELECT * FROM users LIMIT 5`

.

3. Receive the JSON response from your Node script.

4. Formulate a natural language answer.

It's a far cry from the old way of manually exporting data.

## Why this beats generic plugins

The beauty of an MCP protocol guide is realizing that the "intelligence" isn't just in the model—it's in the context you provide. By building your own server, you aren't relying on some third-party company to build an integration for your specific database schema. You control the permissions. You control the data.

If you get stuck on the TypeScript types or the JSON-RPC handshake, looking through [Resources](/en/category/resources/) can save you a few hours of debugging.

## Refining the "skills"

Once you have a basic connection, you can expand. I found that adding a `list_tables`

tool was essential because Claude doesn't know your schema by default. Without it, the LLM just guesses table names and throws errors.

Add this to your `ListToolsRequestSchema`

handler:

```
{
  name: "list_tables",
  description: "List all tables in the database to understand the schema",
  inputSchema: { type: "object", properties: {} }
}
```

And handle it in the `CallToolRequestSchema`

using `SELECT name FROM sqlite_master WHERE type='table'`

.

## Scaling your workflow with a community

Building these tools in a vacuum is slow. The wild part is how many people are already creating specialized MCP servers for everything from Jira API wrappers to local filesystem indexers. Instead of rewriting the wheel for every project, you can find pre-made configurations through [Prompt Sharing](/en/category/prompts/) to see how others structure their tool definitions to get better LLM reasoning.

Joining a Generative AI Community like PromptCube is basically a shortcut for this. Instead of guessing why your server is crashing on startup, you can find a dev who already solved that specific `stdio`

hang-up.

The real shift happens when you stop treating the AI as a consultant and start treating it as an operator with a set of tools. Once you move from "Tell me how to write this SQL" to "Analyze this data for me," your productivity doesn't just increase—it changes shape.

[Next AWS Bedrock gives you three times more notice than Anthropic for →](/en/threads/6193/)

[a guide to making money with AI](https://tanyan888.com/), with plenty of directly applicable cases.

## All Replies （0）

No replies yet — be the first!
