Contractor Scale Context MCP Server
Enables AI agents to access Contractor Scale internal context, including client background, meeting transcripts, and team summaries, via three tools: list_clients, get_client_context, and get_meetings.
README
Contractor Scale Context MCP Server
Internal MCP server for Contractor Scale client context, meeting records, and strategy summaries. Built on Cloudflare Workers with Supabase and the Contractor Scale context API.
Overview
This MCP (Model Context Protocol) server gives AI agents like TypingMind, ClickUp Brain, and other MCP clients access to Contractor Scale internal context β client background, meeting transcripts, and team huddles β through a single connection.
Key Features
- π 3 Context Tools β List clients, fetch full client context, search meetings
- π Dual Transport β Streamable HTTP (
POST /mcp) for modern clients + legacy SSE (GET /sse) for TypingMind - π Cloudflare Workers β Serverless, stateless session handling across worker isolates
- ποΈ Supabase Integration β Client lookup via
master_clients, meeting search viameetings - π Context API β Full client summaries from
contractor-scale-api.onrender.com - π Dual API Key Auth β
API_KEYfor MCP clients;CONTEXT_API_KEYfor the context API
Architecture
ββββββββββββββββββββββββββββββββ
β AI Clients β
β (TypingMind, ClickUp, etc.) β
ββββββββββββββββ¬ββββββββββββββββ
β MCP Protocol
β β’ Streamable HTTP β POST /mcp
β β’ Legacy SSE β GET /sse
β
ββββββββββββββββΌβββββββββββββββββββββββββ
β Cloudflare Worker β
β API_KEY (inbound) β
β βββββββββββββββββββββββββββββββββββββ β
β β 3 Context Tools β β
β β β’ list_clients β β
β β β’ get_client_context β β
β β β’ get_meetings β β
β βββββββββββββββββ¬ββββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββ
β
βββββββββββ΄βββββββββββ
β β
βββββββββΌβββββββββ ββββββββββΌβββββββββββββββββββββββββββββββ
β Supabase β β Contractor Scale Context API β
β ββββββββββββββ β β contractor-scale-api.onrender.com β
β βmaster_ β β β GET /client-context/{client} β
β β clients β β β Header: X-API-Key: CONTEXT_API_KEY β
β βmeetings β β βββββββββββββββββββββββββββββββββββββββββ
β ββββββββββββββ β
ββββββββββββββββββ
Endpoints
| Endpoint | Method | Purpose |
|---|---|---|
/ |
GET | Health check (no API key required) |
/mcp |
POST | Streamable HTTP MCP transport (ClickUp, modern clients) |
/mcp |
DELETE | Terminate MCP session |
/sse |
GET | Legacy SSE connection (TypingMind) |
/sse |
POST | Direct MCP message (no session) |
/sse/message |
POST | MCP message with SSE session |
Health check response includes version, toolCount, tools, and available endpoints.
MCP protocol version: 2025-03-26
Authentication:
- MCP endpoints (
/mcp,/sse) requireX-API-Key: API_KEY(except health check/) get_client_contextcalls the context API withX-API-Key: CONTEXT_API_KEY
Session handling: Streamable HTTP uses stateless Mcp-Session-Id headers (no in-memory session store), which is required for Cloudflare Workers where requests may hit different isolates.
Available Tools (3)
list_clients
List all available client names from the master_clients table. Use these names with clientName in other tools.
Input: none
get_client_context
Get the full context summary for a client including meetings, messages, and overall strategy. Use when asked about a specific client's background, history, or current status.
Input:
| Parameter | Type | Required | Description |
|---|---|---|---|
clientName |
string | yes | Client name as stored in master_clients |
Behavior:
- Validates the client exists in
master_clients - Fetches
https://contractor-scale-api.onrender.com/client-context/{clientName}(URL-encoded) with headerX-API-Key: CONTEXT_API_KEY - Returns the text response from the API
get_meetings
Search and retrieve meeting records including summaries, full transcripts, and recording URLs. Use when asked what was discussed in a meeting, what a client said, or what tasks were mentioned in a team huddle.
Inputs:
| Parameter | Type | Required | Description |
|---|---|---|---|
clientName |
string | no | Resolved to location_id via master_clients |
meetingTitle |
string | no | Partial text search on meeting_title |
meetingDate |
string | no | ISO date (YYYY-MM-DD) to filter meetings on that date |
inviteeName |
string | no | Search within the invitees_name array column |
category |
string | no | Filter on category or category_auto: team, client, or other |
output |
string | no | What to return: summary (default), full_transcript, or recording_url |
Behavior:
- Builds a Supabase query on the
meetingstable using whichever parameters are provided - If no parameters are provided, returns the 10 most recent meetings ordered by
meeting_datedescending - Always includes
meeting_title,meeting_date,invitees_name, andcategoryin results
Prerequisites
- Node.js 18+ (for local development)
- Cloudflare Workers account
- Supabase account with
master_clientsandmeetingstables - TypingMind, ClickUp Brain, or another MCP-compatible client
Database Schema
Your Supabase database must have these tables:
master_clients table:
CREATE TABLE master_clients (
id SERIAL PRIMARY KEY,
client_name TEXT UNIQUE NOT NULL,
location_id TEXT NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
meetings table:
CREATE TABLE meetings (
id SERIAL PRIMARY KEY,
location_id TEXT,
meeting_title TEXT,
meeting_date TIMESTAMPTZ,
invitees_name TEXT[],
category TEXT,
category_auto TEXT,
summary TEXT,
full_transcript TEXT,
recording_url TEXT,
created_at TIMESTAMP DEFAULT NOW()
);
Installation
1. Clone the Repository
git clone https://github.com/isaganiesteron/contractor-scale-context-mcp.git
cd contractor-scale-context-mcp
2. Install Dependencies
npm install
3. Configure Environment Variables
Set credentials in wrangler.jsonc under vars:
"vars": {
"API_KEY": "your-mcp-api-key",
"CONTEXT_API_KEY": "your-context-api-key",
"SUPABASE_URL": "https://your-project.supabase.co",
"SUPABASE_SERVICE_KEY": "your-service-role-key"
}
| Variable | Purpose |
|---|---|
API_KEY |
Authenticates MCP clients to this worker (X-API-Key on /mcp, /sse) |
CONTEXT_API_KEY |
Authenticates this worker to the context API (X-API-Key on contractor-scale-api.onrender.com) |
For local dev you can also use .dev.vars (same variable names). On deploy, values in wrangler.jsonc β vars are injected as worker environment variables.
Note:
wrangler.jsoncis gitignored β copywrangler.jsonc.exampleand fill in your credentials locally.
Development
Local Development
npm run dev
The server will start on http://localhost:8787
Run Tests
npm test
Deployment
Deploy to Cloudflare Workers
npm run deploy
Configure Secrets
Credentials are set in wrangler.jsonc β vars. Update CONTEXT_API_KEY there, then redeploy:
npm run deploy
Verify Deployment
curl https://contractor-scale-context-mcp.isagani.workers.dev/
Expected response:
{
"name": "contractor-scale-context-mcp",
"version": "1.0.2",
"status": "running",
"toolCount": 3,
"tools": ["list_clients", "get_client_context", "get_meetings"],
"endpoints": { "sse": "/sse", "mcp": "/mcp" }
}
Production URL: https://contractor-scale-context-mcp.isagani.workers.dev
Usage
Configure in ClickUp Brain (Streamable HTTP)
- URL:
https://contractor-scale-context-mcp.isagani.workers.dev/mcp - Auth:
X-API-Keyheader with yourAPI_KEYvalue
After connecting, disconnect and reconnect if tools don't appear β clients cache the tool list from tools/list.
Configure in TypingMind (Legacy SSE)
Add to your TypingMind MCP configuration:
{
"mcpServers": {
"contractor-scale-context": {
"url": "https://contractor-scale-context-mcp.isagani.workers.dev/sse",
"transport": "sse",
"name": "Contractor Scale Context"
}
}
}
Example Queries
List available clients:
User: "What clients are available?"
Get client background and strategy:
User: "What's the current status and strategy for Bear Construction?"
Search recent meetings:
User: "What was discussed in our last team huddle?"
Find meetings for a specific client:
User: "Show me recent meetings with ABC Remodeling"
Get a full transcript:
User: "Get the full transcript of yesterday's client call with Bear Construction"
(The AI will call get_meetings with clientName, meetingDate, and output: "full_transcript".)
Error Handling
The server provides clear error messages:
"Client 'ABC Remodeling' not found"β Invalid client name (includes available clients when possible)"No meetings matched the criteria."β No results for the given filters"Failed to fetch client context"β Context API returned an error (checkCONTEXT_API_KEY)"CONTEXT_API_KEY is not configured on the worker"β MissingCONTEXT_API_KEYinwrangler.jsonc"API key required"/"Invalid API key"β MCP authentication failure (API_KEY)
Production Debugging
Structured JSON logs are emitted for wrangler tail:
wrangler tail
Key log events: request.received, route.matched, mcp.method.parsed, mcp.tools.call, mcp.response.sent, mcp.session.created, auth.failed.
Troubleshooting
Issue: "Session not found" (ClickUp / Streamable HTTP)
Cause: Client is using a stale tool list or an old server build.
Fix:
- Verify health check shows
toolCount: 3and the expectedtoolsarray - Disconnect and reconnect the MCP integration in ClickUp
- Ensure you are using
POST /mcp, not/sse
Issue: "Client not found"
Check:
- Client exists in
master_clientstable client_namespelling matches (case-insensitive fallback is supported)
Fix:
- Add client to
master_clientstable - Use
list_clientsto see exact names
Issue: "No meetings matched the criteria"
Check:
- Filters are not too restrictive
location_idinmeetingsmatches the client'slocation_idinmaster_clients- Date format is
YYYY-MM-DD
Fix:
- Call
get_meetingswith no parameters to see the 10 most recent meetings - Broaden filters (e.g. drop
meetingTitleorinviteeName)
Issue: Context API fetch fails (401 Unauthorized)
Check:
CONTEXT_API_KEYis set inwrangler.jsoncβvars- The key matches what
contractor-scale-api.onrender.comexpects - Client exists in
master_clients - Worker has been redeployed after updating the key
Fix:
// wrangler.jsonc
"vars": {
"CONTEXT_API_KEY": "your-context-api-key"
}
Then run npm run deploy.
Issue: Context API fetch fails (other errors)
- Client exists in
master_clients contractor-scale-api.onrender.comis reachable- The client has context data on the API
Security
Authentication
- Inbound: MCP clients authenticate with
API_KEYviaX-API-Keyon/mcpand/sse - Outbound: Worker authenticates to the context API with
CONTEXT_API_KEYviaX-API-Key - Credentials are configured in
wrangler.jsoncβvars(gitignored, not committed) - No credentials exposed in logs or error messages
Data Privacy
- Meeting and client data served on demand from Supabase and the context API
- Logs do not contain PII beyond what is needed for debugging
Project Structure
contractor-scale-context-mcp/
βββ src/
β βββ index.ts # MCP server, tool definitions, routing
β βββ lib/
β βββ supabase.ts # Supabase client factory
β βββ client-resolver.ts # Client name β location ID lookup
β βββ tool-result.ts # MCP result helpers
β βββ types.ts # Shared type definitions
βββ test/
β βββ index.spec.ts
βββ postman/ # API test collections
βββ wrangler.jsonc.example # Cloudflare Workers config template
βββ package.json
βββ tsconfig.json
βββ README.md
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT License - see LICENSE file for details
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: isagani@contractorscale.com
Acknowledgments
- Built with Model Context Protocol
- Powered by Cloudflare Workers
- Database by Supabase
- Template based on typingmind-mcp-cloudflare-starter
Related Projects
- TypingMind β AI chat interface with MCP support (SSE)
- ClickUp β Project management with Brain AI (Streamable HTTP)
Built with β€οΈ by Isagani Esteron at Contractor Scale
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.