Claude Code (CLI)

Set up ContextPin with Claude Code command-line tool.

Claude Code is Anthropic's command-line interface for Claude, designed for developers who prefer working in the terminal. This guide shows you how to connect ContextPin to Claude Code.

Configuration

Claude Code uses a .mcp.json file in your project directory or home directory for MCP configuration.

Project-Level Configuration

Create .mcp.json in your project root for project-specific contexts:

{
  "mcpServers": {
    "contextpin": {
      "command": "/Applications/ContextPin.app/Contents/MacOS/contextpin-mcp",
      "args": ["--workspace", "YOUR_WORKSPACE_ID"]
    }
  }
}

Global Configuration

Create ~/.mcp.json for contexts available in all projects:

# macOS/Linux
~/.mcp.json

# Windows
%USERPROFILE%\.mcp.json

Getting Your Configuration

  1. Open ContextPin
  2. Go to Settings → MCP
  3. Select Claude Code as the target
  4. Click Copy Configuration
  5. Paste into your .mcp.json file

Platform-Specific Paths

macOS

{
  "mcpServers": {
    "contextpin": {
      "command": "/Applications/ContextPin.app/Contents/MacOS/contextpin-mcp",
      "args": ["--workspace", "YOUR_WORKSPACE_ID"]
    }
  }
}

Windows

{
  "mcpServers": {
    "contextpin": {
      "command": "C:\\Program Files\\ContextPin\\contextpin-mcp.exe",
      "args": ["--workspace", "YOUR_WORKSPACE_ID"]
    }
  }
}

Linux

{
  "mcpServers": {
    "contextpin": {
      "command": "/opt/contextpin/contextpin-mcp",
      "args": ["--workspace", "YOUR_WORKSPACE_ID"]
    }
  }
}

Verify the Connection

Start Claude Code and verify the connection:

# Start Claude Code in your project
cd your-project
claude

# In Claude Code, ask:
"List my ContextPin contexts"

You should see your contexts listed. If connected, you'll also see ContextPin mentioned when Claude Code starts.

Usage Examples

# List contexts
> List my ContextPin contexts

# Read a specific context
> Read my API Guidelines context

# Use context for code review
> Using my Code Standards, review this file: src/api/users.ts

# Generate code following guidelines
> Based on my React Component Guidelines, create a UserCard component

# Search contexts
> Search my contexts for authentication patterns

Workflow Tips

Project-Specific Contexts

Keep project-specific contexts in a workspace and use a project-level .mcp.json that points to that workspace.

Quick Reference

Add frequently-referenced contexts to your prompts:

> Using @[Code Standards] and @[Error Handling], fix the bug in auth.ts

Pipeline Integration

Claude Code can be used in scripts. Your contexts are available:

echo "Review src/api.ts against my API Guidelines" | claude

Troubleshooting

MCP Server Not Found

  • Verify the path in your .mcp.json is correct
  • Check that ContextPin is installed at that location
  • Make sure ContextPin is running

Config File Not Loading

  • Check file location: .mcp.json in project root or home directory
  • Verify JSON syntax is correct
  • Try running Claude Code with --debug flag for more info

Workspace ID Issues

  • Get the correct workspace ID from ContextPin Settings → MCP
  • Make sure you're not using placeholder text
  • Check for typos in the workspace ID

Permission Errors

# macOS: Grant execute permission
chmod +x /Applications/ContextPin.app/Contents/MacOS/contextpin-mcp

# Linux
chmod +x /opt/contextpin/contextpin-mcp

Next Steps