Skip to content

Add tools for STD documentation access #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Andrey Ryapov, Other contributors
Copyright (c) 2024 Andrey Ryapov, "Zig and WebAssembly" contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Zig Docs MCP

MCP server providing up-to-date Zig documentation and builtin functions.
Model Context Protocol (MCP) server that provides up-to-date documentation for the Zig programming language standard library and builtin functions.

> [!TIP]
> Add `use zigdocs` to your prompt if you want to explicitly instruct the LLM to use Zig docs tools. Otherwise, LLM will automatically decide when to utilize MCP tools based on the context of your questions.

## Installation

Expand Down
5 changes: 5 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
"formatter": {
"indentWidth": 2
}
},
{
"includes": ["docs/main.js"],
"formatter": { "enabled": false },
"linter": { "enabled": false }
}
]
}
45 changes: 45 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const std = @import("std");

pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseSmall });

const wasm_target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
.cpu_features_add = std.Target.wasm.featureSet(&.{
.atomics,
.bulk_memory,
.multivalue,
.mutable_globals,
.nontrapping_fptoint,
.reference_types,
.sign_ext,
}),
});

const wasm_exe = b.addExecutable(.{
.name = "main",
.root_module = b.createModule(.{
.root_source_file = b.path("docs/wasm/main.zig"),
.target = wasm_target,
.optimize = optimize,
}),
});

const walk_module = b.createModule(.{
.root_source_file = b.path("docs/wasm/Walk.zig"),
});
wasm_exe.root_module.addImport("Walk", walk_module);

wasm_exe.entry = .disabled;
wasm_exe.rdynamic = true;

const install_wasm = b.addInstallArtifact(wasm_exe, .{
.dest_dir = .{ .override = .prefix },
});

b.installFile("docs/index.html", "index.html");
b.installFile("docs/main.js", "main.js");

b.getInstallStep().dependOn(&install_wasm.step);
}
44 changes: 44 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Zig Documentation</title>
<style>
body {
font-family: monospace;
font-size: 14px;
margin: 20px;
}
#search {
width: 100%;
padding: 10px;
margin-bottom: 20px;
border: 1px solid #555;
font-family: monospace;
}
#content {
white-space: pre-wrap;
line-height: 1.4;
}
.hidden {
display: none;
}
#errors {
background: #400;
padding: 10px;
margin: 10px 0;
border: 1px solid #600;
}
</style>
</head>
<body>
<input type="search" id="search" autocomplete="off" spellcheck="false" placeholder="Search documentation...">
<div id="content"></div>
<div id="errors" class="hidden">
<h1>Errors</h1>
<pre id="errorsText"></pre>
</div>
<script src="main.js"></script>
</body>
</html>
Loading