GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - mthds-ai/mthds-starter-js: A minimal Next.js 16 starter that runs MTHDS methods from a TypeScript app through the mthds SDK.

BranchesTags
Open more actions menu

Latest commit

 

History

14 Commits
14 Commits

Folders and files

NameName
Last commit message
Last commit date
.claude/skills
.claude/skills
 
 
.github/workflows
.github/workflows
 
 
.husky
.husky
 
 
docs
docs
 
 
e2e
e2e
 
 
methods
methods
 
 
public
public
 
 
src
src
 
 
.env.example
.env.example
 
 
.gitignore
.gitignore
 
 
.prettierignore
.prettierignore
 
 
.prettierrc
.prettierrc
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CLAUDE.md
CLAUDE.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
eslint.config.mjs
eslint.config.mjs
 
 
next.config.js
next.config.js
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
playwright.config.ts
playwright.config.ts
 
 
postcss.config.js
postcss.config.js
 
 
tailwind.config.ts
tailwind.config.ts
 
 
tsconfig.e2e.json
tsconfig.e2e.json
 
 
tsconfig.json
tsconfig.json
 
 
vitest.config.mts
vitest.config.mts
 
 
vitest.setup.ts
vitest.setup.ts
 
 

Repository files navigation

mthds-starter-js

A minimal Next.js starter for TypeScript developers who want to run MTHDS methods from a web app, through the mthds SDK.

What this repository is

MTHDS is an open standard for AI methods, and a method runs on any MTHDS-compliant runtime. This repository is a Next.js app that runs methods from its Server Actions: each action reads a .mthds bundle from disk, sends it with your inputs to an MTHDS API through the mthds SDK, and turns the output into a typed value the page renders.

Its example methods are presented as tabs, and each is a pattern to copy:

  • Text entities (methods/hello) extracts the people, organizations and dates named in a text you paste.
  • PDF summary (methods/summarize-pdf) reads a PDF you upload and returns its title, its document type and its key points.
  • Image generation (methods/generate-image) turns a text prompt into an image.

Prerequisites

  • Node.js 22 or later.
  • An MTHDS API for the app to call. The mthds SDK speaks the MTHDS protocol, so any MTHDS-compliant API works. Pipelex, the reference runtime, is one of them: you can run its pipelex-api server yourself, which is where the shipped .env.example points, or call Pipelex's hosted API.

Quick start

From the root of a clone of this repository:

cp .env.example .env.local
make install
make dev

.env.local points the app at an MTHDS API on http://127.0.0.1:8081. If yours runs elsewhere or asks for a key, set the two variables under Configuration first. Then open http://localhost:3000 and run a method from any tab.

Configuration

The app reads two variables from .env.local, which git ignores:

Variable Purpose Value in .env.example
MTHDS_BASE_URL Base URL of your MTHDS API, host only, with no path http://127.0.0.1:8081
MTHDS_API_KEY API key the SDK sends to that API as a bearer token test-api-key

Always set MTHDS_BASE_URL: when it is unset, the SDK falls back to its own default API rather than yours.

How it works

  1. The browser calls a Server Action, one per method: runHelloPipeline, runSummarizePdfPipeline or runGenerateImagePipeline.
  2. The action reads the method's .mthds bundle from disk and calls MthdsApiClient.execute() with the method, the pipe to run and the inputs. The method travels as its tree, the files map from each file's path in the method to its content, here the one file main.mthds. The action names the pipe by its qualified reference, the bundle's domain then the pipe's code (hello.extract_entities), so the reference stays exact whatever else is loaded.
  3. The MTHDS API runs the pipe and returns its output, loosely typed.
  4. A parseXxx() narrower in src/types/ checks that output and returns a typed value.
  5. The page renders the value, or <ErrorDisplay> renders the PipelineError the action returned instead of throwing.

When a run fails

Every error the mthds SDK raises carries the MTHDS protocol's problem document, and the app shows each failure from that problem, never from an error's class or message. <ErrorDisplay> shows the problem's title and detail, its next step, and who must act, which sets its tone: amber when the fix is on the app's side (the request, the method or the account), red when it is the API's (its set-up or a failure of the runtime). Under "Technical details" it shows the problem's code and the request id to hand to whoever runs the API. For some next steps the app adds its own help: a missing or refused key shows the MTHDS_API_KEY line for .env.local, a configuration problem points at .env.local or at the API's own set-up, a method that does not validate points at its bundle, and an API that cannot be reached says to start it. A failure the app catches itself, such as an output its narrower cannot read, is shown with the same layout and no code.

A file input, such as the PDF, is read into a data URL in the browser and wrapped in an MTHDS Document input on the server, and a generated image comes back as a URL. File and image inputs explains both.

Project structure

methods/                      # the .mthds bundles, one directory per method
public/sample-invoice.pdf     # sample PDF, so the PDF example works out of the box
src/
  app/                        # Next.js App Router (layout, page, globals.css)
  actions/                    # 'use server' Server Actions, one per method
  lib/
    mthdsClient.ts            # MthdsApiClient singleton
    loadBundle.ts             # reads each .mthds bundle into the method's files map
    errors.ts                 # classifyPipelineError: a problem → PipelineError
    fileEncoding.ts           # data-URL validation + Document input envelope
    clientFile.ts             # browser File → base64 data URL
  components/                 # ExampleTabs + per-example form and result components
  types/                      # concept types + parseXxx() narrowers
e2e/                          # optional Playwright specs
docs/                         # file and image inputs, development

Add your own method

  1. Add methods/<name>/main.mthds. Write it by hand from the MTHDS guide Write your first method, or have Claude Code or Codex build it with the Pipelex plugin.
  2. Add a loader in src/lib/loadBundle.ts, a type and its parseXxx() narrower in src/types/, and a Server Action in src/actions/ that names the pipe as <domain>.<pipe_code>.
  3. Call the action from a component. The example methods are the patterns to copy.

To make this project your own, run /bootstrap in Claude Code: it replaces the template's name, description and license holder everywhere, and resets the version and the changelog.

Documentation

  • File and image inputs: how a file reaches a method, and how a generated image comes back.
  • Development: every make target, the optional end-to-end tests, and working against a local checkout of the mthds SDK.
  • mthds.ai: the MTHDS standard, its language and its protocol.

Develop

Run make all after every change: it runs ESLint, the Prettier check, the TypeScript check, the unit tests and a production build, the same gates as CI. If the Prettier check fails, run make format. Development has the rest.

License

This project is licensed under the MIT license. Runtime dependencies are distributed under their own licenses via npm.

About

A minimal Next.js 16 starter that runs MTHDS methods from a TypeScript app through the mthds SDK.

mthds.ai

Topics

mthdsnextjsstarter-templatetypescript

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.