webmcp

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 1 Imported by: 0

README

webmcp-go

Framework-agnostic Go helpers for WebMCP — the W3C proposal that lets web pages declare structured tools for AI agents (document.modelContext).

Status: early development. The WebMCP spec is in Chrome origin trial (Chrome 149–156) and its API surface has already changed twice. This module currently ships the one piece of server-side plumbing every participating origin needs — the Origin-Trial response header — and stays deliberately small until the spec settles.

Install

go get github.com/seunghan91/webmcp-go

Usage

package main

import (
	"net/http"

	"github.com/seunghan91/webmcp-go"
)

func handler(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("ok"))
}

func main() {
	mux := http.NewServeMux()
	mux.HandleFunc("/", handler)

	wrapped := webmcp.OriginTrial("your-origin-trial-token")(mux)
	http.ListenAndServe(":8080", wrapped)
}

If the token is empty, OriginTrial returns a pass-through middleware. If the response already has an Origin-Trial header — set by an earlier middleware in the chain — OriginTrial leaves it as-is rather than overwriting it.

License

MIT

Documentation

Overview

Package webmcp provides framework-agnostic helpers for WebMCP (https://github.com/webmachinelearning/webmcp) — the W3C proposal that lets web pages declare structured tools for AI agents (document.modelContext).

Status: early development. The WebMCP spec is in Chrome origin trial (Chrome 149-156) and its API surface has already changed twice. This package currently ships the one piece of server-side plumbing every participating origin needs — the Origin-Trial response header — and stays deliberately small until the spec settles.

Index

Constants

View Source
const OriginTrialHeader = "Origin-Trial"

OriginTrialHeader is the HTTP response header name Chrome's origin trial framework expects: "Origin-Trial".

Variables

This section is empty.

Functions

func OriginTrial

func OriginTrial(token string) func(http.Handler) http.Handler

OriginTrial returns a standard net/http middleware that adds the Origin-Trial response header for the given token. If token is empty, the middleware passes requests through unmodified. If the response already carries an Origin-Trial header (set by an earlier middleware in the chain), that value is left untouched — OriginTrial only fills in a missing header, it never overrides one.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL