Expand description
Model Context Protocol (MCP) server for narwhal.
Exposes narwhal’s configured database connections to AI agents (Claude Desktop, Cursor, Continue, Aider, …) over the JSON-RPC 2.0 stdio transport defined by the MCP spec.
§Quick start
use std::sync::Arc;
use narwhal_config::{ConfigPaths, ConnectionsFile, KeyringStore, DynCredentialStore};
use narwhal_mcp::{DriverRegistry, McpServer, ServerContext};
let paths = ConfigPaths::discover()?;
let connections = ConnectionsFile::load(&paths.connections_file())?;
let drivers = Arc::new(DriverRegistry::with_defaults());
let credentials: Arc<dyn DynCredentialStore> = Arc::new(KeyringStore::new());
let ctx = ServerContext::new(drivers, Arc::new(connections), credentials);
McpServer::new(ctx).serve_stdio().await?;§Wire-up for Claude Desktop
// ~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"narwhal": {
"command": "narwhal",
"args": ["mcp"]
}
}
}§Tool surface (v0)
tools::ListConnectionsTool— metadata only, no IO.tools::DescribeSchemaTool— opens a short-lived connection.
run_query / explain_query land in v0.2 once we’ve validated the
read-only enforcement story.
Re-exports§
pub use context::ServerContext;pub use error::McpError;pub use server::McpServer;pub use workspace::Workspace;pub use workspace::WorkspaceError;pub use workspace::WorkspaceFile;
Modules§
- context
- Shared, read-only context handed to every tool invocation.
- error
- Error types for the MCP server.
- json_
value - Convert
narwhal_core::Valueinto the JSON shape an AI agent expects. - protocol
- JSON-RPC 2.0 + Model Context Protocol message types.
- registry
- server
- Stdio-based MCP server loop.
- tools
- Tool registry and the
Tooltrait every executable command implements. - workspace
- Workspace discovery —
.narwhal/workspace.toml.