How to Use an MCP Server: Complete Setup & Configuration Guide
Learn how to use an MCP server step-by-step. Configure Model Context Protocol servers in Claude Desktop, Cursor, and custom AI agents with real code.

To use an MCP Server (Model Context Protocol Server), you configure an MCP Client (like Claude Desktop, Cursor IDE, or a custom agent script) to point to the server executable. The client launches the server as a local sub-process over stdio or connects remotely over Server-Sent Events (SSE). Once connected, the AI model automatically discovers all available tools, resources, and prompt templates, allowing you to query databases, search codebases, and trigger workflows directly from your chat window.
What is the Use of an MCP Server?
Before jumping into configuration, let's clarify what an MCP server is used for:
- Database Access: Allows AI models to run validated SQL queries against PostgreSQL, SQLite, or Snowflake without exposing raw credentials.
- Git & Code Intelligence: Gives your AI assistant real-time access to inspect commits, review branch diffs, and create PRs in GitHub or GitLab.
- Filesystem & Local Tools: Enables your IDE agent to read and write files safely within designated project sandboxes.
- Corporate Memory & Search: Connects agents to knowledge engines like Memora, letting them answer questions using historical Slack discussions, Jira tickets, and architecture decisions.
Key Takeaways
- No bespoke API coding required: Simply add a few lines of JSON configuration to your AI client to connect any MCP server.
- Claude Desktop configuration: Managed via
claude_desktop_config.jsonlocated in your system Application Support / AppData directory. - Cursor and IDE support: Modern IDEs support both command-line (
stdio) and remote (sse) MCP servers directly in their settings. - Official SDKs: Anthropic provides official SDKs in TypeScript (
@modelcontextprotocol/sdk) and Python (mcp) for connecting custom agents. - Automatic capability discovery: You do not need to manually teach the LLM how to call your server; it inspects schemas automatically upon startup.
Step 1: Locating an MCP Server to Use
You can use pre-built MCP servers or write your own. Popular community and enterprise servers include:
@modelcontextprotocol/server-postgres: Read-only and read-write PostgreSQL database integration.@modelcontextprotocol/server-filesystem: Secure local file exploration.@modelcontextprotocol/server-github: Repository searching, file inspection, and PR automation.memora-mcp-server: Enterprise knowledge graph and corporate memory retrieval.
Most servers can be executed instantly using npx (Node.js) or uvx (Python) without manual installation.
Step 2: How to Configure and Use an MCP Server in Claude Desktop
Claude Desktop is the most popular desktop client for MCP servers.
1. Locate Your Configuration File
Open your OS-specific configuration path:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
2. Add Your MCP Servers to mcpServers
Edit the JSON file to define your servers:
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/username/Projects/my-app"
]
},
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://postgres:password@localhost:5432/analytics_db"
]
},
"memora-memory": {
"command": "npx",
"args": ["-y", "@memora/mcp-server"],
"env": {
"MEMORA_API_KEY": "mem_live_xxxxxxxxxxxx",
"WORKSPACE_ID": "ws_engineering"
}
}
}
}
3. Restart Claude Desktop and Verify
- Completely quit Claude Desktop (
Cmd + QorAlt + F4) and re-launch it. - Look at the bottom-right corner of the chat input box. You will see a small hammer icon (π οΈ).
- Click the hammer icon. You should see a list of tools registered by your MCP servers (e.g.,
read_file,list_directory,query_database,search_corporate_memory). - Ask Claude a question:
"What tables exist in our postgres analytics database, and how many users signed up this week?"
Claude will automatically call the database tool, execute the query, and summarize the output!
Step 3: How to Use an MCP Server in Cursor IDE
Cursor natively supports Model Context Protocol servers to enhance AI coding context:
- Open Cursor Settings (
Cmd + ,on Mac orCtrl + ,on Windows). - Navigate to Features βββΊ MCP Servers.
- Click Add New MCP Server.
- Configure the server parameters:
- Name:
Enterprise Memory - Type:
command(for local stdio) orsse(for remote servers) - Command:
npx -y @memora/mcp-server
- Name:
- Click Save. The green status indicator will verify that Cursor successfully established a handshake with the MCP server.
Now in Cursor's Composer or Chat (Cmd + L), you can type:
"@Enterprise Memory: What was the architectural rationale for migrating to Redis in PR #104?"
Cursor queries the MCP server and pulls historical pull request context directly into your editor!
Step 4: How to Use an MCP Server in Custom Python AI Agents
If you are building your own agent using LangChain, LlamaIndex, or raw LLMs, you can connect directly to any MCP server using the official Python SDK:
import asyncio
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def run_mcp_agent():
# Define server parameters
server_params = StdioServerParameters(
command="npx",
args=["-y", "@modelcontextprotocol/server-filesystem", "./data"],
env=None
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
# Initialize connection
await session.initialize()
# Discover available tools
tools_list = await session.list_tools()
print(f"Connected! Available tools: {[t.name for t in tools_list.tools]}")
# Call a tool programmatically
result = await session.call_tool(
name="read_file",
arguments={"path": "./data/architecture-spec.md"}
)
print("Tool output:", result.content[0].text)
if __name__ == "__main__":
asyncio.run(run_mcp_agent())
Common Troubleshooting & Debugging Tips
1. Command Not Found (PATH Issues on macOS / Windows): If Claude Desktop fails to launch npx or node, it is because desktop GUI apps often don't inherit your terminal's shell PATH. Provide the absolute binary path (e.g. /usr/local/bin/npx or C:\\Program Files\\nodejs\\npx.cmd).
2. Environment Variables Missing
If an MCP server requires authentication (like GitHub tokens or database connection strings), make sure to define them under the "env" object in your configuration JSON rather than relying on system environment variables.
3. Infinite Loops or Tool Timeouts
If an MCP tool query takes longer than 60 seconds (e.g., scanning a 50GB database), the MCP client will timeout. Ensure your server implements pagination or row limits (e.g., LIMIT 50) on queries.
Frequently Asked Questions
How to use an MCP server?
To use an MCP server, add its startup command and arguments to the mcpServers section of your AI client's configuration file (such as claude_desktop_config.json for Claude Desktop or Cursor's MCP settings). Once configured, restart the application, and the AI will automatically discover and execute the tools provided by the server.
What is the use of an MCP server?
The use of an MCP server is to securely bridge an AI model with external data and execution environments. Instead of building custom API plugins, an MCP server standardizes how AI agents read files, execute database queries, inspect git histories, and integrate enterprise SaaS tools like Slack and Jira.
What is an MCP server used for in programming?
In programming, MCP servers are used to connect coding assistants (like Cursor, Claude, or Zed) directly to development environments. They allow AI assistants to read ASTs, search repository diffs, run terminal commands, execute unit tests, and query corporate documentation without leaving the IDE.
Can I run multiple MCP servers at the same time?
Yes. AI clients like Claude Desktop and Cursor can connect to dozens of MCP servers simultaneously. The AI model intelligently routes your prompt to whichever server exposes the specific tool or resource required to answer your question.
Learn More
Explore Memora's foundational guides on Graph RAG, persistent AI memory, and automated knowledge discovery:
Why do standard vector search systems fail on complex technical context?