FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
c15r
c15rContextual
Unlisted
Like
1
Contextual
Home
Code
3
backend
3
shared
1
README.md
Branches
1
Pull requests
Remixes
History
Environment variables
1
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
6/1/2025
Viewing readonly version of main branch: v120
View latest version
README.md

MCP Cognitive Tools Server

A Model Context Protocol (MCP) server that provides cognitive tools for thought processes, goal tracking, and dynamic skill creation with user registration and email verification.

Try it out here: https://www.val.town/x/c15r/Chat

Features

User Management

  • Email Registration: Register with email verification
  • Access Tokens: Secure token-based authentication
  • User-Scoped Resources: All resources are isolated per user
  • Admin Access: Admin users can access legacy global resources

Core Cognitive Tools

  • AI-Enhanced Thought Forking: Automatically generate parallel explorations using OpenAI
  • Goal Tracking: Create, update, and monitor goals with hierarchical structure
  • Task Management: Break down goals into actionable tasks with state tracking
  • State Management: Track and persist cognitive states across sessions
  • Blob Storage: Secure key-value storage with automatic user namespacing
  • Resource Deletion: Full deletion support with foreign key dependency handling

Dynamic Skills System

  • Skill Creation: Write and store reusable scripts as "skills"
  • Skill Execution: Dynamically invoke created skills as tools
  • Skill Management: List, update, and delete skills with execution history

Enhanced Thought Forking

  • Automatic AI Generation: Create thought forks with 2-8 parallel AI-generated explorations
  • Perspective Analysis: AI generates diverse analytical perspectives automatically
  • AI Synthesis: Merge explorations using AI to create comprehensive insights
  • Insight Extraction: Automatically extract key insights from each exploration

Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts        # Database schema (user-scoped + legacy)
│   │   ├── queries.ts           # Database operations with user scoping
│   │   └── user-queries.ts      # User management operations
│   ├── mcp/
│   │   ├── server.ts            # MCP server implementation
│   │   ├── auth.ts              # Authentication (admin + user tokens)
│   │   └── tools/               # Cognitive tools
│   │       ├── blob.ts          # Blob storage management
│   │       ├── fork-thought.ts  # AI-enhanced thought forking
│   │       ├── goals.ts         # Goal management with deletion
│   │       ├── tasks.ts         # Task management with deletion
│   │       ├── states.ts        # Cognitive state management
│   │       ├── skills.ts        # Dynamic skills with deletion
│   │       └── user-registration.ts # User registration & verification
│   └── index.ts                 # Main entry point with verification endpoint
├── shared/
│   └── types.ts                 # Shared TypeScript types (user-scoped)
└── README.md

Environment Variables

  • MCP_AUTH_TOKEN: Admin authentication token (optional)
  • BASE_URL: Base URL for email verification links (optional)

API Endpoints

  • GET / - API documentation and status
  • GET /health - Health check endpoint
  • POST /register - User registration (no auth required)
  • GET /verify?token=... - Email verification (no auth required)
  • POST /mcp - Main MCP protocol endpoint (conditional auth)
  • GET /tools - List available tools (conditional auth)

Getting Started

1. Register a User Account

# Register via HTTP endpoint curl -X POST https://your-server.com/register \ -H "Content-Type: application/json" \ -d '{"email": "user@example.com"}' # Or via MCP (no auth required) { "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "register_user", "arguments": { "email": "user@example.com" } } }

2. Verify Email

Check your email and click the verification link, or visit:

https://your-server.com/verify?token=YOUR_VERIFICATION_TOKEN

3. Use Your Access Token

Use the access token from the verification page in the Authorization header:

curl -X POST https://your-server.com/mcp \ -H "Authorization: YOUR_ACCESS_TOKEN" \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'

Enhanced Thought Forking

Create AI-enhanced thought forks that automatically generate multiple perspectives:

{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "create_thought_fork", "arguments": { "title": "AI Ethics in Healthcare", "description": "Explore the ethical implications of AI in medical diagnosis and treatment", "branches": 4 } } }

This will:

  1. Create a thought fork
  2. Generate 4 different analytical perspectives using AI
  3. Create parallel explorations for each perspective
  4. Extract key insights from each exploration
  5. Return the complete thought fork with all explorations

Merge the explorations with AI synthesis:

{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "merge_thought_fork", "arguments": { "id": "thought-fork-id" } } }

Blob Storage Management

The blob storage system provides secure, user-namespaced key-value storage for arbitrary data:

{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "blob_set", "arguments": { "key": "user-preferences", "value": { "theme": "dark", "language": "en", "notifications": true } } } }

Retrieve stored data:

{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "blob_get", "arguments": { "key": "user-preferences" } } }

List all your stored blobs:

{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "blob_list", "arguments": { "prefix": "config-" } } }

Blob Storage Features

  • Automatic Namespacing: All blob keys are automatically prefixed with your user ID
  • JSON Support: Automatic JSON serialization/deserialization (can be disabled)
  • Prefix Filtering: List blobs with specific prefixes
  • Existence Checking: Check if a blob exists without retrieving its value
  • Admin Access: Admin users can access global blob storage
  • Secure Isolation: Users can only access their own blobs

Resource Management

All resources support full deletion with dependency handling:

  • Goals: Deleting a goal removes all subgoals and associated tasks
  • Tasks: Deleting a task removes it from goals and other task dependencies
  • Thought Forks: Deleting removes all associated explorations
  • Skills: Deleting removes all execution history
  • States: Direct deletion of cognitive states

Authentication Types

User Authentication

  • Obtained through email verification
  • Scoped to user's own resources
  • Required for all cognitive tools

Admin Authentication

  • Set via MCP_AUTH_TOKEN environment variable
  • Access to legacy global resources
  • Full system access

Public Access

  • User registration tools only
  • No authentication required

MCP Tool Categories

Registration Tools (No Auth)

  • register_user - Register with email
  • verify_email - Verify email with token
  • resend_verification - Resend verification email

Cognitive Tools (Auth Required)

  • Blob Storage: blob_list, blob_get, blob_set, blob_delete, blob_exists
  • Thought Forking: create_thought_fork, merge_thought_fork, delete_thought_fork
  • Goals: create_goal, update_goal, delete_goal, list_goals
  • Tasks: create_task, update_task, delete_task, list_tasks
  • States: save_cognitive_state, load_cognitive_state, delete_cognitive_state
  • Skills: create_skill, execute_skill, delete_skill, list_skills

Dynamic Skills (Auth Required)

  • skill_[name] - Execute user-created skills dynamically

Example Workflow

  1. Register: register_user with email
  2. Verify: Click email link to get access token
  3. Store Data: Use blob_set to store configuration or data
  4. Create Goal: Use create_goal to set objectives
  5. Fork Thoughts: Use create_thought_fork for AI-assisted analysis
  6. Merge Insights: Use merge_thought_fork for AI synthesis
  7. Create Tasks: Break down goals with create_task
  8. Build Skills: Create reusable tools with create_skill
  9. Save State: Capture progress with save_cognitive_state

Security Features

  • Email verification required for access
  • User-scoped resource isolation
  • Automatic blob storage namespacing
  • Secure skill execution sandboxing
  • Token-based authentication
  • Foreign key constraint handling

Server Version: 2.0.0 - Now with user registration and AI-enhanced cognitive tools

Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.