Skip to content

major-technology/mcp-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Organization Tools

This repository contains custom agent tools for your organization. Each tool is a folder in tools/ with a tool.json and index.ts. The package manager is pnpm.

Tool Structure

tools/
  my-tool/
    tool.json             # Tool metadata with UUID
    index.ts              # Tool implementation (exports default async function)
    src/clients/          # Auto-generated resource clients
    resources.json        # Auto-generated resource registry

tool.json Format

{
  "id": "<auto-generated uuid>",
  "name": "my-tool",
  "description": "What the tool does",
  "inputSchema": {
    "type": "object",
    "properties": {
      "param1": { "type": "string", "description": "..." }
    },
    "required": ["param1"]
  }
}

index.ts Format

Every tool's index.ts default-exports a handler that receives two arguments: the tool input and a context object injected per-request by the MCP server.

import { createMyDbClient } from "./src/clients";

interface ToolInput {
  param1: string;
}

interface ToolContext {
  resourceApiUrl: string;
  majorJwtToken: string;
}

export default async function(input: ToolInput, context: ToolContext) {
  const db = createMyDbClient(context);
  const result = await db.invoke("SELECT ...", [], "my-query");

  if (!result.ok) {
    throw new Error(result.error.message);
  }

  return result.result;
}

Never read auth values from process.env -- always use context.

Adding Resource Clients

cd tools/<tool-name>
pnpx major-client add "<resourceId>" "<clientName>" "<type>" "<description>" --mode tool

This creates type-safe factory functions in src/clients/ with the tool's ID from tool.json hardcoded at generation time. Create a client instance inside the handler on every call -- do not cache globally. If the tool's UUID changes, regenerate all resource clients.

Dependencies

All tools share the root package.json. To add a dependency:

pnpm add <package-name>

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors