Skip to content

alvinycheung/claude-code-template-palantir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quick Start

To get started, run the following command:

bash scripts/configure_mcp.sh

This script will guide you through the process of setting up your environment variables and configuring the MCP connections for both Claude and Gemini.

Palantir Foundry AI-Assisted Development Template

A comprehensive template for developing Palantir Foundry applications with integrated AI code assistants (Claude Code and Google Gemini CLI).

Prerequisites

  • Node.js (v18 or higher)
  • npm or yarn
  • Access to Palantir Foundry with:
    • Platform administrator has enabled Palantir MCP
    • Generated user token
    • Your enrollment URL (e.g., stack123.palantirfoundry.com)
    • Compass project RID for default resource creation

Initial Setup

1. Clone and Configure

# Clone this template
git clone <your-repo-url> my-palantir-project
cd my-palantir-project

# Set up environment variables
export FOUNDRY_TOKEN="your-palantir-user-token"

2. Configure npm Registry

Configure npm to authenticate with Palantir's artifact registry:

npm config set //$(echo "https://your-enrollment.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/" | sed 's/https:\/\///')/:_auth $FOUNDRY_TOKEN

Replace your-enrollment with your actual enrollment URL.

3. Update Configuration Files

For Claude Code

Edit .mcp.json and replace the placeholders:

{
  "mcpServers": {
    "Palantir": {
      "command": "npx",
      "args": [
        "-y",
        "@palantir/mcp@latest",
        "--foundry-api-url",
        "https://your-enrollment.palantirfoundry.com",
        "--default-foundry-folder",
        "ri.compass.folder.your-project-rid"
      ],
      "env": {
        "FOUNDRY_TOKEN": "your-token-here",
        "NPM_CONFIG_REGISTRY": "https://your-enrollment.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/"
      },
      "disabled": false
    }
  }
}

For Gemini CLI

Create or update ~/.gemini/settings.json:

mkdir -p ~/.gemini
cat > ~/.gemini/settings.json << 'EOF'
{
  "mcpServers": {
    "Palantir": {
      "command": "npx",
      "args": [
        "-y",
        "@palantir/mcp@latest",
        "--foundry-api-url",
        "https://your-enrollment.palantirfoundry.com",
        "--default-foundry-folder",
        "ri.compass.folder.your-project-rid"
      ],
      "env": {
        "FOUNDRY_TOKEN": "your-token-here",
        "NPM_CONFIG_REGISTRY": "https://your-enrollment.palantirfoundry.com/artifacts/api/repositories/ri.artifacts.repository.discovered.foundry-mcp/contents/release/npm/"
      }
    }
  }
}
EOF

Remember to replace:

  • your-enrollment with your Palantir enrollment URL
  • your-token-here with your generated user token
  • ri.compass.folder.your-project-rid with your Compass project RID

4. Verify Setup

Claude Code:

# Start Claude in the project
claude

# List MCP servers
claude mcp list

# Test Palantir connection
> Can you list the datasets in my Foundry folder?

Gemini CLI:

# Check MCP configuration
gemini /mcp

# Test in agent mode
gemini --agent
> Show me the datasets in my default Foundry folder

Project Structure

.
├── .claude/                    # Claude Code configuration
│   ├── commands/              # Custom Claude commands
│   ├── settings.json          # Base permissions
│   └── settings.local.json    # Local permissions
├── .mcp.json                  # MCP server configuration
├── ai_docs/                   # AI assistant documentation
│   ├── palantir-patterns.md   # Common Foundry patterns
│   └── foundry-best-practices.md # Best practices guide
├── specs/                     # Project specifications
│   ├── code-standards.md      # Code standards
│   ├── project-management.md  # Project management
│   └── project_plan.md        # Master project plan
├── foundry/                   # Foundry-specific code
│   ├── transforms/           # Data transformation code
│   ├── functions/           # Foundry Functions
│   └── pipelines/           # Pipeline definitions
├── scripts/                   # Utility scripts
└── CLAUDE.md                  # Claude-specific instructions

Using with Palantir Foundry

Available MCP Tools

Once connected, AI assistants have access to:

  • Dataset Operations: Read, write, query, and transform datasets
  • Code Repository Management: Create and manage Foundry code repositories
  • Pipeline Execution: Trigger builds and monitor pipeline status
  • Ontology Access: Query and manipulate ontology objects
  • Function Execution: Run Foundry Functions
  • File Management: Upload and manage files in Foundry

Example Commands

Dataset Operations:

# With Claude Code
> Show me the schema of the customer_transactions dataset
> Create a transform that aggregates daily sales by region
> Write a Python transform to clean the raw_inventory data

# With Gemini CLI
> List all datasets modified in the last week
> Generate a PySpark transform to join customer and order datasets

Pipeline Management:

# With Claude Code
> Check the status of the daily_aggregation pipeline
> Create a new pipeline that runs the data quality checks

# With Gemini CLI
> Show me failed builds from the last 24 hours
> Set up a pipeline to run every 6 hours

Ontology Operations:

# With Claude Code
> Query all Customer objects where revenue > 1000000
> Create a new ontology type for Product with appropriate properties

# With Gemini CLI
> Show the relationships between Customer and Order objects
> Update the Customer object type to include a new property

Development Workflow

1. Starting a New Feature

# Load project context
claude
> /prime

# Work on a JIRA ticket
> /work_on_ticket_engineer PROJ-123

2. Data Transformation Development

# Create a new transform
> Create a new Python transform in foundry/transforms/ that processes daily_sales data

# The AI will:
# - Create the transform file
# - Set up proper imports
# - Implement the transformation logic
# - Add error handling
# - Create unit tests

3. Pipeline Development

# Create a pipeline
> Set up a pipeline that orchestrates the customer data processing workflow

# The AI will:
# - Define pipeline stages
# - Set up dependencies
# - Configure scheduling
# - Add monitoring and alerts

Best Practices

Security

  1. Never commit tokens: Use environment variables for sensitive data
  2. Token rotation: Regularly rotate your Foundry user tokens
  3. Access control: Follow principle of least privilege
  4. Code review: Always review AI-generated code before deployment

Development

  1. Use version control: Commit changes frequently with meaningful messages
  2. Test thoroughly: Ensure transforms work with sample data before full runs
  3. Monitor performance: Check dataset size and processing times
  4. Document changes: Keep README and specs updated

AI Assistant Usage

  1. Be specific: Provide clear requirements and constraints
  2. Verify outputs: Always review generated code and queries
  3. Iterative development: Build complex transforms incrementally
  4. Use examples: Provide sample data or expected outputs when possible

Customization

Adding Project Context

Edit CLAUDE.md to include:

  • Specific dataset schemas and relationships
  • Common transformation patterns used in your project
  • Ontology object definitions
  • Team conventions and standards

Extending AI Capabilities

Add documentation in ai_docs/:

  • palantir-patterns.md - Common Foundry development patterns
  • dataset-schemas.md - Dataset schemas and relationships
  • transform-library.md - Reusable transformation code
  • ontology-guide.md - Ontology structure and usage

Troubleshooting

MCP Connection Issues

  1. Verify token is set correctly:

    echo $FOUNDRY_TOKEN
  2. Check npm configuration:

    npm config get registry
  3. Test MCP directly:

    npx -y @palantir/mcp@latest --foundry-api-url https://your-enrollment.palantirfoundry.com --help

Common Issues

  • "Unauthorized" errors: Token may be expired or incorrect
  • "Not found" errors: Check enrollment URL and project RID
  • Connection timeouts: Verify network access to Palantir
  • MCP not available: Ensure platform admin has enabled MCP

Support Resources

Contributing

When contributing to this template:

  1. Never commit credentials or tokens
  2. Test changes with both AI assistants
  3. Update documentation for new features
  4. Follow Palantir's best practices
  5. Ensure code passes Foundry's quality checks

Important: This template requires proper Palantir Foundry access and MCP enablement. Contact your Palantir administrator if you encounter access issues.

About

Claude Code Template for Palantir Foundry Development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages