23- Respond in a friendly and concise manner
24- Ask clarifying questions when requirements are ambiguous
25- Provide complete, functional solutions rather than skeleton implementations
26- Test your logic against edge cases before presenting the final solution
27- Ensure all code follows Val Town's specific platform requirements
36- **Never bake in secrets into the code** - always use environment variables
37- Include comments explaining complex logic (avoid commenting obvious operations)
38- Follow modern ES6+ conventions and functional programming practices where appropriate
3940### Val Town Utility Functions
4142Val Town provides several utility functions to help with common project tasks. These utilities handle file management, project information, and testing.
4344### Importing Utilities
90{
91name: "should add numbers correctly",
92function: () => {
93expect(1 + 1).toBe(2);
94},
174โ โโโ database/
175โ โ โโโ migrations.ts # Schema definitions
176โ โ โโโ queries.ts # DB query functions
177โ โ โโโ README.md
178โ โโโ index.ts # Main entry point
190โโโ shared/
191โโโ README.md
192โโโ utils.ts # Shared types and functions
193```
194196- Hono is the recommended API framework (similar to Express, Flask, or Sinatra)
197- Main entry point should be `backend/index.ts`
198- **Static asset serving:** Use the utility functions to read and serve project files:
199```ts
200// Use the serveFile utility to handle content types automatically
237- Run migrations on startup or comment out for performance
238- Change table names when modifying schemas rather than altering
239- Export clear query functions with proper TypeScript typing
240- Follow the queries and migrations pattern from the example
241
3*
4* This is the HTTP entry point for the ValTown MCP Server when deployed
5* on ValTown itself. It excludes CLI-dependent functionality and uses
6* header-based authentication with Hono and StreamableHTTPServerTransport.
7*/
val-town-http-mcp-serverfileTools.ts2 matches
16* 5. Clean up workspace
17*/
18async function performFileOperationWithCli(
19config: Config,
20valId: string,
88}
8990export function registerFileTools(server: McpServer, config: Config) {
91// List files in a val branch
92server.tool(
4* @returns A string representation of the error
5*/
6export function getErrorMessage(error: unknown): string {
7if (error instanceof Error) {
8return error.message
2import * as path from "jsr:@std/path"
3import {getCliAvailability} from "./lib/vtCli.ts"
4export async function loadConfig(remoteMode = false) {
5if (remoteMode) {
6// For remote: expect token in request headers, use local prompt file
8import {getErrorMessage} from "../lib/errorUtils.ts";
910export function registerCliTools(server: McpServer, _config: Config) {
11// Watch files in a project for real-time updates
12server.tool(
val-town-http-mcp-serverCLAUDE.md3 matches
89## Style Guidelines
10- Use TypeScript strict mode with explicit typing for function parameters/returns
11- 2-space indentation, semicolons at line ends
12- Use camelCase for variables/functions, PascalCase for types/interfaces, UPPER_SNAKE_CASE for constants
13- Tool names use kebab-case (e.g., `get-val`)
14- Document all public functions with JSDoc
15- Wrap async operations in try/catch blocks and use getErrorMessage utility
16- Return consistent error responses with isError flag
6import {z} from "npm:zod"
78export function registerBranchTools(server: McpServer, config: Config) {
9// List all branches in a val
10server.tool(
5import {getErrorMessage} from "../lib/errorUtils.ts"
67export function registerBlobTools(server: McpServer, config: Config) {
8// List blobs
9server.tool(
1import {Config} from "./types.ts"
23export async function callValTownApi(
4config: Config,
5path: string,