Skip to main content
Glama
README.md
# Project Showcase MCP

An MCP (Model Context Protocol) server that reads GitHub repositories and returns structured data (title, description, README summary, tech stack, screenshots, live link) so a portfolio website's project cards update automatically.

## Features

- **GitHub Integration**: Fetches repo data, languages, README, topics via Octokit
- **Smart Enrichment**: Detects tech stack from languages + manifest files (package.json, etc.)
- **README Summarization**: Extracts 2-3 sentence summaries from README content
- **Screenshot Capture**: Uses Playwright to capture desktop/mobile screenshots of live URLs
- **GitHub Releases Upload**: Uploads screenshots as release assets to a designated repo
- **Flexible Featured Logic**: Supports `.showcase.json` per-repo override + GitHub `featured` topic fallback
- **LLM Verification**: Optional verification loop with prompt caching and disk memoization
- **MCP Tools**: 6 tools, 1 resource, 1 prompt for portfolio integration
- **CLI Commands**: `export` and `verify` subcommands for CI/CD
- **Webhook Receiver**: Separate Express server for GitHub push events

## Quick Start

```bash
# Install dependencies
npm install

# Copy example env file
cp .env.example .env
# Edit .env with your GitHub token and username

# Build
npm run build

# Run MCP server (stdio)
npm run inspect  # Opens MCP Inspector
```

## Configuration

Create a `.showcase.config.json` in your project root:

```json
{
  "github": {
    "username": "your-github-username",
    "token": "env:GITHUB_TOKEN",
    "allowlist": ["repo1", "repo2", "repo3"],
    "includeForks": false,
    "includeArchived": false
  },
  "screenshots": {
    "enabled": true,
    "uploadTo": "github-releases",
    "targetRepo": "username/portfolio-assets",
    "viewport": { "desktop": [1280, 800], "mobile": [390, 844] },
    "waitUntil": "networkidle",
    "timeoutMs": 30000
  },
  "verification": {
    "enabled": true,
    "model": "claude-3-5-haiku-20241022",
    "maxRounds": 2,
    "maxCallsPerRun": 50
  },
  "output": {
    "screenshotsDir": "./showcase-output/screenshots",
    "portfolioJson": "./projects.json"
  }
}
```

### Environment Variables

- `GITHUB_TOKEN` - GitHub personal access token (repo scope)
- `GITHUB_USERNAME` - Your GitHub username
- `ANTHROPIC_API_KEY` - For verification (optional)
- `GITHUB_WEBHOOK_SECRET` - For webhook receiver (optional)

### Per-Repo Override (`.showcase.json`)

Place a `.showcase.json` in any repo root to override defaults:

```json
{
  "featured": true,
  "summary": "Custom summary for portfolio card",
  "liveUrl": "https://my-project.example.com",
  "stack": ["React", "TypeScript", "Tailwind"],
  "topics": ["portfolio", "showcase"],
  "hideFromPortfolio": false
}
```

## MCP Tools

| Tool | Description |
|------|-------------|
| `list_projects` | Filterable project list (featured, topic, language, limit) |
| `get_project` | Single project by slug |
| `refresh_screenshots` | Re-capture screenshots for given slugs |
| `export_portfolio_json` | Write `projects.json` for portfolio |
| `verify_project` | Run verification loop on a project |
| `verification_stats` | Get cache hit/miss/token statistics |

## Resource

- `showcase://projects` — Returns full project array

## Prompt

- `write_project_case_study` — Generates markdown case study from project data

## CLI Commands

```bash
# Export projects to JSON (for portfolio)
npm run export -- --out ./projects.json --verify

# Verify projects
npm run verify -- --all --max-rounds 2

# Validate config
node dist/index.js config
```

## Webhook Receiver

Run a separate process to handle GitHub push events:

```bash
cd webhook-receiver
npm install
npm start
```

Configure GitHub webhook to point to `http://your-host:3001/webhook/github` with events: `push`, `repository`.

## Portfolio Integration (Next.js Example)

See `examples/portfolio-integration/nextjs-portfolio/` for a complete Next.js 14+ App Router example that consumes the exported `projects.json`.

```bash
cd examples/portfolio-integration/nextjs-portfolio
npm install
# Copy projects.json to public/projects.json
npm run dev
```

## Development

```bash
# Watch mode
npm run dev

# Run tests
npm run test

# Lint
npm run lint

# Typecheck
npm run typecheck
```

## Architecture

```
GitHub API → GitHub Client → Enrichment → Verification → MCP Tools/Resources/Prompts
                                      ↓
                            Screenshots (Playwright) → GitHub Releases
                                      ↓
                            CLI Export → projects.json → Portfolio Site
```

## Security

- No secrets in logs (stderr-only structured logging)
- Private/localhost URLs blocked unless `ALLOW_PRIVATE_URLS=true`
- Path traversal protection on output paths
- Webhook signature verification
- Zod validation on all inputs

## License

MIT