Claude Agent SDK + Neo4j Integration
Overview
Claude Agent SDK is Anthropic’s Python toolkit for building AI agents. Built on the same agent harness that powers Claude Code, it provides automatic context management, a rich tool ecosystem, fine-grained permissions, and production essentials like error handling and session management.
Installation:
pip install claude-agent-sdk neo4j
Key Features:
-
Automatic context management across conversations
-
Native MCP (Model Context Protocol) server support
-
Custom tool creation with the
@tooldecorator -
Subagent orchestration for parallel and specialized workflows
-
Session persistence and resumption
-
Support for multiple LLM providers (Anthropic API, AWS Bedrock, Google Vertex AI, Microsoft Azure)
Examples
| Notebook | Description |
|---|---|
Walkthrough of Claude Agent SDK with Neo4j integration, including MCP server setup, custom tool creation, and query execution |
Extension Points
1. MCP Integration
The Claude Agent SDK has native MCP support. MCP servers are added directly to ClaudeAgentOptions via the mcp_servers parameter—no adapters required.
-
Neo4j MCP Server: Leverage existing MCP servers such as
mcp-neo4j-cypherfor ready-made integration
MCP Authentication
Supported Mechanisms:
✅ Environment Variables (STDIO transport) - For local MCP servers like mcp-neo4j-cypher, credentials are passed via the env parameter at spawn time.
✅ HTTP Headers (HTTP/SSE transport) - For remote MCP servers, pass API keys or bearer tokens via the headers parameter (e.g., Authorization: Bearer ${API_TOKEN}).
❌ OAuth 2.0 (in-client) - OAuth2 MCP authentication in-client is not currently supported by the SDK.
Configuration Example (STDIO transport):
cypher_mcp_config = {
"type": "stdio",
"command": "uvx",
"args": ["mcp-neo4j-cypher"],
"env": {
"NEO4J_URI": os.environ.get("NEO4J_URI"),
"NEO4J_USERNAME": os.environ.get("NEO4J_USERNAME"),
"NEO4J_PASSWORD": os.environ.get("NEO4J_PASSWORD"),
"NEO4J_DATABASE": os.environ.get("NEO4J_DATABASE", "neo4j")
}
}