ak-mcp
OfficialThe ak-mcp server provides queryable documentation, API details, and guidance for the AK (Active Kernel) event-driven MCU framework, helping AI tools generate correct firmware code. Key capabilities include:
Search AK Docs (
search_ak_docs): Full-text BM25 search across AK concepts, guides, guardrails, and API entries, with optional filtering by section (api,concept,guide,guardrail).Get AK API Entry (
get_ak_api): Retrieve exact signatures, parameters, return values, semantics, usage examples, and FATAL error codes for specific AK kernel functions, macros, or types (e.g.,timer_set,task_post_pure_msg).List AK API (
list_ak_api): Browse all AK kernel API symbols with one-line summaries, optionally filtered by module (task,message,timer,fsm,tsm,ak,port).Get AK How-To Guide (
get_ak_guide): Step-by-step recipes with skeleton code and wiring instructions for common tasks likecreate-task,create-driver,create-screen,isr-bridge,tune-pools, anduse-timer.Get AK Guardrails (
get_ak_guardrails): Mandatory rules and kernel invariants for AK development (e.g., no blocking, fixed pools, 64-byte payload, max 7 refs, priority 0 reserved) — essential before generating any code.Start New AK Projects: Resolve the latest base-kit release and get setup commands and a customization plan.
Analyze AK Debug Logs: Process raw UART output to get structured diagnoses for FATAL errors, timing problems, or reboot loops.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@ak-mcp show me the API signature for ak_timer_start"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
AK Active Kernel documentation MCP server
| EN | VN |
A free, public Model Context Protocol server that gives AI coding tools accurate, queryable knowledge base for the AK (Active Kernel) event-driven MCU framework (firmware: ak-base-kit-stm32l151).
It lets an AI assistant:
Understand the AK kernel core (scheduler, message pools, timers, FSM/TSM),
Look up exact API signatures and arguments (extracted straight from the headers, so they never drift),
Follow the rules & format for creating tasks, drivers, and screens,
Design new tasks/drivers without touching the kernel, boot, sys, networks, or common code.
(*) Deeply understanding your product is the root of automation success !
How it works
This repo is standalone - the kernel headers are vendored (committed) under
vendor/ak-inc/, so nothing else needs to be cloned to build it.
vendor/ak-inc/*.h ──────────────► scripts/extract.mjs ─┐ (snapshot of the kernel
▲ refreshed by │ headers; refresh with
scripts/fetch-headers.mjs (GitHub) ├─► npm run fetch-headers)
corpus/ (hand-written guides, scripts/build-corpus ┘─► generated/corpus.json
guardrails, enrichment) ───────────────────────────► (docs + BM25 index)
│
src/core (resources + tools + prompts)
├── src/worker -> Cloudflare Worker (remote HTTP)
└── src/cli -> npx ak-mcp (stdio, local)Signatures come from the vendored kernel headers; semantics/examples are layered on per symbol (corpus/enrichment/). A CI drift check fails if any cross-reference points at a symbol the headers no longer define.
Related MCP server: jlink-mcp
What it exposes
Tools
Tool | Purpose |
| resolve the latest base-kit release and return download/extract commands + a customization plan |
| BM25 search across everything |
| exact signature, params, returns, semantics, examples, FATAL codes |
| browse the API by module (task/message/timer/fsm/tsm/ak/port) |
| recipes: start-project, create-task, create-driver, create-screen, use-timer, isr-bridge, tune-pools, debug-uart-shell, kernel-task-log, agent-workflow |
| do-not-modify zones + kernel invariants |
| paste raw UART output -> structured diagnosis: FATAL cause/fix, timing (run-to-completion/starvation), reboot loops, next shell commands |
| paste a |
Prompts: ak-new-project, ak-new-task, ak-new-driver, ak-debug - guided scaffolding/debugging that enforces conventions and guardrails.
Debugging loop: the board's only debug surface is its 115200 UART console (leveled printf
an interactive shell). Agents capture it non-interactively with
examples/ak-console.py(pyserial; destructive shell commands are blocked unless--allow-destructive), then feed the text toanalyze_ak_log.
Resources: ak://index, and ak://{section}/{id} for every concept, guide, guardrail, and API entry.
Kernel headers (vendored)
The build reads the AK kernel's public headers, which are committed under vendor/ak-inc/
(a snapshot of a firmware release tag - see vendor/ak-inc/SOURCE.txt). Cloning this repo is
enough to build it: no firmware checkout required.
Refresh the snapshot when the kernel changes:
npm run fetch-headers # pinned default tag (v1.3)
npm run fetch-headers v1.4 # a specific release tagthen npm run build:corpus and commit vendor/ak-inc/. Header resolution order (first
existing wins) - override only if you want to build against a live firmware checkout:
$AK_INC_DIR- exact path to.../application/sources/ak/inc$AK_FIRMWARE_DIR/application/sources/ak/inc- a firmware repo rootvendor/ak-inc/- the committed snapshot (default)
Once generated/corpus.json is built, the running server (stdio or Worker) needs nothing
external - the corpus is self-contained.
Develop
npm install
npm run build:corpus # generate generated/corpus.json from the headers + corpus/
npm run drift # build + fail on broken cross-references
npm test # extractor, corpus integrity, and search ranking (no deps needed)
npm run typecheck # core + cliThe corpus pipeline (scripts/*.mjs) and tests are zero-dependency and run on plain Node ≥ 20 - no install required for npm run build:corpus / node --test (only the firmware headers must be reachable as above).
Run locally (stdio)
npm run build # build:corpus + tsc -> dist/
node dist/cli/bin.js # or, after publishing: npx -y ak-mcpInspect it with the MCP Inspector:
npx @modelcontextprotocol/inspector node dist/cli/bin.jsClient config (Claude Desktop / Cursor):
{ "mcpServers": { "ak": { "command": "npx", "args": ["-y", "ak-mcp"] } } }Deploy (remote, public)
The Worker bundles corpus.json at build time, so it needs no database.
npm run dev # local Streamable HTTP at http://localhost:8787/mcp
npm run deploy # build:corpus + wrangler deployEndpoints: /mcp (Streamable HTTP), /sse (legacy), / (landing page).
Remote client config:
{ "mcpServers": { "ak": { "url": "https://ak-mcp.<your-account>.workers.dev/mcp" } } }Using it in VS Code (vibe coding): see docs/vscode-vibe-coding.md
for step-by-step setup (Copilot Agent mode, Cursor, Cline, Claude Code), a copy-paste
.vscode/mcp.json template, and a project steering file
(examples/copilot-instructions.md).
CI (.github/workflows/ak-mcp.yml) builds from the vendored headers (no firmware checkout):
verify runs build + drift + tests + typecheck on every change, and deploy ships from main
when CLOUDFLARE_API_TOKEN and CLOUDFLARE_ACCOUNT_ID secrets are set. A refresh-headers job
(manual Run workflow with an optional tag, or a repository_dispatch of type
firmware-updated from the firmware repo) re-fetches vendor/ak-inc/, verifies it, and commits
the update if anything changed.
Adding knowledge base
The kernel released a new version? Run
npm run fetch-headers [<tag>]to refreshvendor/ak-inc/, thennpm run build:corpusand commit the snapshot. New/changed signatures are then extracted automatically.A new API needs prose? Add
corpus/enrichment/<symbol>.mdto give it semantics/examples (the signature is already extracted).A new recipe or concept? Add a markdown file under
corpus/guides/orcorpus/concepts/with frontmatter (id,title,tags,summary, optionalapis).Run
npm run driftto verify all references resolve.
Enrichment / content frontmatter:
---
symbol: timer_set # enrichment only
summary: One-line summary.
fatal_codes: MT:0x30
see_also: timer_remove_attr, timer_tick
tags: timer, periodic
---
Markdown body (semantics, examples) ...Available Tools
8 toolsanalyze_ak_logAnalyze AK UART logA
Paste raw UART console output from an AK board (boot logs, -SIG-> traces, FATAL banners, fatal l/fatal m dumps, timing lines) and get a structured diagnosis: detected FATAL codes with cause and fix, run-to-completion/starvation timing issues, reboot-loop detection, and the exact shell commands to run next.
Inputs: log (required), context.
decode_ak_lcdDecode AK OLED framebufferA
See the board's OLED screen headlessly: paste the raw output of the shell command lcd d (the 0xNN,0xNN,... framebuffer dump) and get the screen rendered as text art plus a PNG image, with content stats. Format: 128x64 @ 1bpp, page-major, LSB = top pixel (Adafruit_oled_drv).
Inputs: dump (required), scale, invert.
get_ak_apiGet AK API entryA
Exact signature, parameters, return value, semantics, examples, and FATAL codes for an AK kernel function, macro, or type (e.g. 'timer_set', 'task_post_pure_msg').
Inputs: symbol (required).
get_ak_guardrailsGet AK guardrailsA
The rules every AK contribution must follow: which directories are off-limits (kernel, boot, networks, common) and the kernel invariants (no blocking, fixed pools, 64-byte payload, max 7 refs, priority 0 reserved). Consult before generating code.
Inputs: no named parameters.
get_ak_guideGet AK how-to guideA
Step-by-step recipe (with skeleton code, Makefile.mk steps, and wiring) for a common AK task. Topics: agent-workflow, create-driver, create-screen, create-task, debug-uart-shell, isr-bridge, kernel-task-log, start-project, tune-pools, use-timer.
Inputs: topic (required).
list_ak_apiList AK APIA
List AK kernel API symbols, optionally filtered by module (task, message, timer, fsm, tsm, ak, port), each with a one-line summary.
Inputs: module.
search_ak_docsSearch AK docsA
Full-text search across AK concepts, guides, guardrails, and API entries. Returns ranked results with resource URIs.
Inputs: query (required), limit, section.
start_ak_projectStart a new AK projectA
Begin a new firmware project from the AK base kit. Resolves the LATEST ak-base-kit-stm32l151 release (or a given tag) and returns the exact commands to download, extract, and lay out the project, plus the steps to customize it. Call this when an engineer wants to start/create/bootstrap a new AK-based project.
Inputs: ref, project_name.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
Each tool has a clearly distinct purpose: search, API details, API listing, guide, guardrails, project start, log analysis, LCD decode. No overlap or ambiguity.
All tools follow a consistent verb_noun pattern with underscores, using the 'ak' prefix (search_ak_docs, get_ak_api, etc.), making them predictable and easy to understand.
Eight tools is well-scoped for an embedded firmware development assistant. It covers documentation, API reference, guides, project initialization, and debugging without being overwhelming or too sparse.
The tool set covers key developer workflows: searching docs, retrieving API signatures, getting guides and rules, starting projects, and analyzing logs and LCD output. Minor gaps like a build tool or flash utility are likely out of scope.
Maintenance
Related MCP Connectors
Versioned documentation registry and semantic search for AI tools and coding assistants.
Provide your AI coding tools with token-efficient access to up-to-date technical documentation for…
AI-native programming language and toolchain for accountable, verifiable agent-driven development.
Project memory, documentation and controlled secret access for AI coding agents.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides AI agents with professional coding standards, development best practices, and context-aware guidance through static documentation and AI-powered custom recommendations. Enables agents to access comprehensive development guidelines including coding rules, debugging techniques, and AI steering instructions.-
- AlicenseAqualityDmaintenanceEnables AI assistants like Claude to directly debug microcontrollers via JLink, supporting breakpoints, single-step, memory/register access, variable inspection, RTT logging, and firmware flashing.257MIT
- AlicenseAqualityCmaintenanceProvides documentation search, reading, and AI-powered Q\&A for ArkTS/ArkUI development, enabling AI coding assistants to answer questions and retrieve official docs.743MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-driven embedded development: generate, build, flash, and debug firmware using natural language commands through MCP.MIT