Ad Space (horizontal)
Advanced

Claude Code MCP Server Setup और Practical Use Cases

Claude Code की MCP server capabilities की comprehensive guide। External tools connect करना, servers configure करना, और real-world integration examples सीखें।

MCP क्या है?

MCP (Model Context Protocol) AI assistants को external tools और data sources से connect करने का एक open protocol है। Claude Code एक MCP client के रूप में काम करता है, जिससे यह MCP servers के through databases, APIs, और विभिन्न services के साथ interact कर सकता है।

MCP Servers Configure करना

MCP server settings .claude/settings.json या ~/.claude/settings.json में जाती हैं:

{
  "mcpServers": {
    "server-name": {
      "command": "executable-command",
      "args": ["arg1", "arg2"],
      "env": {
        "ENV_VAR": "value"
      }
    }
  }
}

CLI से भी servers add कर सकते हैं:

claude mcp add server-name -- command arg1 arg2

Example 1: Database Integration

PostgreSQL पर directly queries run करने के लिए MCP server setup करें:

claude mcp add postgres-server -- npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost:5432/mydb

Configure होने के बाद, Claude Code session से ही अपना database query कर सकते हैं:

> Count the new user registrations from the past week in the users table
> Show the daily trend in a table format

Claude Code automatically SQL queries generate और execute करता है, फिर results आपके लिए format करता है।

Example 2: GitHub Integration

GitHub MCP server से issues और PRs directly Claude Code से manage कर सकते हैं:

claude mcp add github -- npx -y @modelcontextprotocol/server-github

Environment variables से token setup करें:

{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_xxxxxxxxxxxx"
      }
    }
  }
}

आप ये कर सकते हैं:

> List all open issues in the repository
> Look at Issue #42, create a fix branch, and implement the solution
> Once the fix is done, create a PR

Example 3: Filesystem Extension

एक specific directory को safe access provide करने वाला MCP server:

claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /path/to/allowed/directory

Example 4: Web Scraping

Puppeteer MCP server web page fetching और interaction enable करता है:

claude mcp add puppeteer -- npx -y @modelcontextprotocol/server-puppeteer
> Read the API documentation at https://example.com/api/docs
> and create a client library for that API

Example 5: Slack Integration

Slack MCP server से channels से messages read कर सकते हैं और notifications send कर सकते हैं:

{
  "mcpServers": {
    "slack": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-slack"],
      "env": {
        "SLACK_BOT_TOKEN": "xoxb-xxxxxxxxxxxx"
      }
    }
  }
}
> Check the latest messages in #dev
> Post today's progress update to #daily-report

MCP Servers Manage करना

Registered Servers List करें

claude mcp list

Server Remove करें

claude mcp remove server-name

Scope Set करना

MCP servers के लिए configuration scope specify कर सकते हैं:

# Project-local (default)
claude mcp add --scope project db-server -- command

# User-global
claude mcp add --scope user db-server -- command

Custom MCP Server बनाना

Project-specific tools custom MCP servers के रूप में भी बना सकते हैं:

// my-mcp-server.ts
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer({
  name: "my-project-tools",
  version: "1.0.0",
});

// Custom tool define करें
server.tool(
  "deploy-staging",
  "Staging environment में deploy करें",
  { branch: z.string().describe("Deploy करने वाली branch का नाम") },
  async ({ branch }) => {
    // Deployment logic
    return {
      content: [{ type: "text", text: `Deployed ${branch} to staging` }],
    };
  }
);

const transport = new StdioServerTransport();
await server.connect(transport);

इसे ऐसे register करें:

claude mcp add my-tools -- npx tsx my-mcp-server.ts

Security Considerations

1. Credential Management

MCP server configs में tokens और passwords को environment variables या .env files से manage करना चाहिए। इन्हें Git में कभी commit न करें।

2. Access Scope Limit करें

Least privilege principle follow करें — उदाहरण के लिए, database MCP server के लिए read-only database user use करें।

3. Local Settings Use करें

Credentials वाले configs को .claude/settings.local.json में store करें और .gitignore में add करें।

Conclusion

MCP servers Claude Code की capabilities को आपके पूरे project ecosystem में extend करते हैं। Database queries से GitHub workflows से Slack notifications तक, आप Claude Code को अपने development workflow के central hub के रूप में use कर सकते हैं। Official MCP servers से शुरू करें, फिर ज़रूरत के अनुसार custom servers बनाएं।

Ad Space (rectangle)
#Claude Code #MCP #MCP server #integrations #extensions