Advanced Topics

MCP & AI Setup

MCP & AI Integration Setup

Set up Model Context Protocol (MCP) to work with AI assistants like Claude in your Stellify projects.

Repository

stellify-mcp - MCP server for Stellify platform integration

What is MCP?

Model Context Protocol (MCP) is a standardized way for AI assistants to interact with external systems. The Stellify MCP server allows AI assistants to:

  • Read your Stellify project code
  • Understand your application structure
  • Create and modify files
  • Execute code and see results
  • Help with debugging and development

Supported AI Assistants

  • Claude Desktop - Anthropic's desktop app
  • Claude Code (CLI) - Command-line interface
  • Any MCP-compatible client

Prerequisites

System Requirements

  • Node.js 18+ or Python 3.10+
  • Claude Desktop app or Claude Code CLI
  • Stellify account with API access
  • Active Stellify project

Generate API Token

  1. Log into Stellify
  2. Navigate to SettingsAPI Tokens
  3. Click Generate New Token
  4. Name it: "MCP Integration"
  5. Copy the token (you won't see it again)

Installation

Option 1: Node.js Installation

npm install -g @stellify/mcp-server

Or use npx (no installation):

npx @stellify/mcp-server

Option 2: Python Installation

pip install stellify-mcp

Option 3: From Source

git clone https://github.com/Stellify-Software-Ltd/stellify-mcp.git
cd stellify-mcp
npm install
npm run build
npm link

Configuration

For Claude Desktop

Edit Claude Desktop config file:

macOS:

~/Library/Application Support/Claude/claude_desktop_config.json

Windows:

%APPDATA%\Claude\claude_desktop_config.json

Linux:

~/.config/Claude/claude_desktop_config.json

Add Stellify MCP server:

{
  "mcpServers": {
    "stellify": {
      "command": "node",
      "args": [
        "/path/to/stellify-mcp/build/index.js"
      ],
      "env": {
        "STELLIFY_API_TOKEN": "your_api_token_here",
        "STELLIFY_PROJECT_ID": "your_project_uuid_here",
        "STELLIFY_API_URL": "https://api.stellisoft.com"
      }
    }
  }
}

Or if installed globally:

{
  "mcpServers": {
    "stellify": {
      "command": "stellify-mcp",
      "env": {
        "STELLIFY_API_TOKEN": "your_api_token_here",
        "STELLIFY_PROJECT_ID": "your_project_uuid_here"
      }
    }
  }
}

For Claude Code (CLI)

Create ~/.claude/mcp_config.json:

{
  "mcpServers": {
    "stellify": {
      "command": "stellify-mcp",
      "env": {
        "STELLIFY_API_TOKEN": "your_api_token_here",
        "STELLIFY_PROJECT_ID": "your_project_uuid_here"
      }
    }
  }
}

Environment Variables

Alternatively, use environment variables:

export STELLIFY_API_TOKEN="your_token"
export STELLIFY_PROJECT_ID="your_project_id"
export STELLIFY_API_URL="https://api.stellisoft.com"  # Optional

Then simplified config:

{
  "mcpServers": {
    "stellify": {
      "command": "stellify-mcp"
    }
  }
}

Verifying Setup

Test Connection

stellify-mcp --test

Output should show:

✓ Connected to Stellify API
✓ Project found: My Stellify App
✓ MCP server ready

In Claude Desktop

  1. Restart Claude Desktop
  2. Start a new conversation
  3. Type: "What files are in my Stellify project?"
  4. Claude should list your project files

If Claude responds with actual file names, MCP is working!

Using AI with Stellify

Basic Interactions

View Project Structure

You: Show me the structure of my Stellify project

Claude: Your project has the following structure:
- Controllers:
  - UserController (5 methods)
  - PostController (7 methods)
- Models:
  - User
  - Post
  - Comment
- Routes: 15 defined routes

Read Code

You: Show me the UserController index method

Claude: Here's the index method from UserController:

public function index()
{
    $users = User::all();
    return view('users.index', ['users' => $users]);
}

Explain Code

You: What does the store method in PostController do?

Claude: The store method creates a new post. It:
1. Validates the request data (title, body required)
2. Associates the post with the authenticated user
3. Saves to the database
4. Redirects to the post view

Code Generation

Create New Controller

You: Create a CommentController with CRUD methods

Claude: I'll create a CommentController with standard CRUD operations...

[Claude creates the controller in Stellify with:
- index() - List all comments
- store() - Create new comment
- update() - Update comment
- destroy() - Delete comment]

Created CommentController in your Stellify project.

Generate Model

You: Create a Comment model with relationships to User and Post

Claude: I'll create a Comment model with those relationships...

[Claude creates model with:
- belongsTo(User)
- belongsTo(Post)
- fillable fields
- validation rules]

Created Comment model in your project.

Add Method to Existing Controller

You: Add a search method to UserController that filters by name

Claude: I'll add a search method...

public function search(Request $request)
{
    $query = $request->input('query');
    $users = User::where('name', 'LIKE', "%{$query}%")->get();
    return view('users.index', ['users' => $users]);
}

Method added to UserController.

Debugging

Find Errors

You: My UserController store method isn't working. Can you help?

Claude: Let me check the store method...

I see the issue. You're calling User::create() but haven't defined $fillable on the User model. This causes a mass assignment exception.

Fix: Add this to User model:
protected $fillable = ['name', 'email', 'password'];

Review Code Quality

You: Review my UserController for best practices

Claude: I've reviewed UserController. Here are some suggestions:

1. Add validation in store method
2. Use Form Requests for complex validation
3. Add try-catch for database operations
4. Use route model binding in show/update/destroy
5. Consider adding pagination to index method

Would you like me to implement any of these?

Refactoring

Improve Code

You: Refactor UserController to use repository pattern

Claude: I'll refactor to use repository pattern...

[Claude:
1. Creates UserRepository
2. Updates controller to use repository
3. Adds dependency injection
4. Updates methods]

Refactored UserController to use UserRepository.

Add Features

You: Add email verification to the User model

Claude: I'll add email verification functionality...

[Claude:
1. Adds email verification fields to model
2. Creates verification method
3. Adds route for verification
4. Creates controller method]

Email verification added to User model and routes.

MCP Tools Available

The Stellify MCP server provides these tools to Claude:

File Operations

  • list_files - List all files in project
  • read_file - Read specific file content
  • create_file - Create new file (controller, model, etc.)
  • update_file - Modify existing file
  • delete_file - Remove file

Code Operations

  • list_methods - List methods in a file
  • read_method - Get specific method code
  • create_method - Add new method to file
  • update_method - Modify existing method
  • execute_method - Run method and see output

Project Operations

  • get_routes - List all routes
  • create_route - Add new route
  • get_models - List all models
  • get_project_structure - Get full project structure

Element Operations (UI)

  • list_elements - List UI elements
  • create_element - Add new UI element
  • update_element - Modify UI element

Advanced Configuration

Multiple Projects

Connect to multiple Stellify projects:

{
  "mcpServers": {
    "stellify-prod": {
      "command": "stellify-mcp",
      "env": {
        "STELLIFY_API_TOKEN": "prod_token",
        "STELLIFY_PROJECT_ID": "prod_project_id"
      }
    },
    "stellify-dev": {
      "command": "stellify-mcp",
      "env": {
        "STELLIFY_API_TOKEN": "dev_token",
        "STELLIFY_PROJECT_ID": "dev_project_id"
      }
    }
  }
}

In Claude:

You: Using stellify-dev, show me the UserController

Custom API URL

For self-hosted Stellify:

{
  "env": {
    "STELLIFY_API_URL": "https://stellify.yourcompany.com/api"
  }
}

Read-Only Mode

Prevent AI from making changes:

{
  "env": {
    "STELLIFY_READ_ONLY": "true"
  }
}

Debug Mode

Enable verbose logging:

{
  "env": {
    "STELLIFY_DEBUG": "true",
    "STELLIFY_LOG_FILE": "/tmp/stellify-mcp.log"
  }
}

Workflows with AI

Workflow 1: Rapid Prototyping

  1. Describe feature: "Build a blog post system with comments"
  2. Claude creates:
    • Post and Comment models
    • Controllers with CRUD
    • Routes
    • Basic views
  3. Refine: "Add user authentication to posts"
  4. Test: Run methods in Stellify
  5. Deploy: Export and deploy

Workflow 2: Code Review

  1. Request review: "Review my entire project for security issues"
  2. Claude analyzes all controllers and models
  3. Provides feedback with specific issues
  4. Suggests fixes and implements if approved
  5. Verify: Test changes in Stellify

Workflow 3: Documentation Generation

  1. Request docs: "Generate README for this project"
  2. Claude reads all files and routes
  3. Creates documentation with:
    • API endpoints
    • Model relationships
    • Setup instructions
  4. Export: Save documentation to project

Workflow 4: Test Writing

  1. Request tests: "Write tests for UserController"
  2. Claude creates test file with:
    • Unit tests for all methods
    • Mock data setup
    • Assertions
  3. Run tests: Execute in test environment
  4. Fix issues: Claude helps debug failures

Troubleshooting

MCP Server Not Starting

Error: Cannot connect to Stellify API

  • Check API token is correct
  • Verify internet connection
  • Check API URL (if custom)

Error: Project not found

  • Verify project ID is correct
  • Ensure project exists in your account
  • Check token has access to project

Claude Can't See Project

Restart Claude Desktop:

  • Quit Claude Desktop completely
  • Restart the application
  • MCP servers load on startup

Check Configuration:

stellify-mcp --validate-config

Permission Errors

Error: Insufficient permissions

  • Regenerate API token with full access
  • Check token hasn't expired
  • Verify project membership

Rate Limiting

If hitting rate limits:

  • Reduce request frequency
  • Use caching where possible
  • Contact support for limit increase

Security Best Practices

API Token Security

  1. Never commit tokens - Keep out of version control
  2. Use environment variables - Don't hardcode
  3. Rotate regularly - Generate new tokens periodically
  4. Limit scope - Use read-only when possible

Access Control

  1. Project-specific tokens - Don't use account-wide tokens
  2. Revoke unused tokens - Clean up old tokens
  3. Monitor usage - Check API logs for suspicious activity

Review AI Changes

  1. Always review - Don't blindly accept AI suggestions
  2. Test thoroughly - Run tests after AI modifications
  3. Version control - Commit changes with descriptive messages
  4. Rollback plan - Know how to revert if needed

Best Practices

Effective Prompts

Good Prompts:

  • "Create a UserController with standard CRUD methods"
  • "Add validation to the store method in PostController"
  • "Refactor CommentController to use repository pattern"

Avoid:

  • "Make it better" (too vague)
  • "Fix everything" (too broad)
  • "Do something with users" (unclear)

Iterative Development

  1. Start small - Build one feature at a time
  2. Test frequently - Verify each change works
  3. Iterate - Refine based on results
  4. Document - Keep track of changes

Collaborative AI

  1. Be specific - Provide context and requirements
  2. Ask questions - Claude can explain anything
  3. Request options - Ask for multiple approaches
  4. Learn - Use AI as a teaching tool

Examples

Example 1: Complete CRUD

You: Create a complete CRUD system for managing tasks
- Task model with title, description, due_date, completed
- TaskController with all CRUD methods
- Routes for the controller
- Add validation

Claude: [Creates everything and responds]
Created Task model with fields: title, description, due_date, completed
Created TaskController with methods: index, create, store, show, edit, update, destroy
Added routes to routes/web.php
Added validation rules to all methods

Your task management system is ready to use.

Example 2: API Development

You: Convert my UserController to a RESTful API controller
- Return JSON responses
- Add proper status codes
- Include error handling
- Add API authentication

Claude: [Converts controller]
Converted UserController to API controller:
- All methods now return JSON
- Added proper HTTP status codes (200, 201, 404, 422)
- Added try-catch blocks with error responses
- Added middleware('auth:api') for authentication

Your API is ready. Test with: GET /api/users

Example 3: Database Design

You: I need a database structure for an e-commerce site with:
- Products with categories
- Shopping cart
- Orders and order items
- User addresses

Claude: [Creates models and migrations]
Created models:
- Product (belongsTo Category, hasMany OrderItems)
- Category (hasMany Products)
- Cart (belongsTo User, hasMany CartItems)
- CartItem (belongsTo Cart, belongsTo Product)
- Order (belongsTo User, hasMany OrderItems)
- OrderItem (belongsTo Order, belongsTo Product)
- Address (belongsTo User)

Created migrations for all tables with proper foreign keys.
Relationships are properly configured.

Next Steps


Ready to code with AI? Set up the stellify-mcp server and start building!

Please be aware that our documentation is under construction.