Skip to content

Tooling MCP

Liu.Yandong.Hanks edited this page Aug 19, 2026 · 3 revisions

MCP 服务

MCP Server

适用版本:4.0.0

Applies to 4.0.0.

工具链 · API 参考

Tooling · API Reference

AuroraScript.Mcp 是面向支持 Model Context Protocol 的 AI 客户端的 stdio 服务器。它提供语言资料、schema、示例、脚本检查、运行和诊断解释;通信通道为 stdin/stdout JSON-RPC,不能向 stdout 写入额外日志。

AuroraScript.Mcp is a stdio server for AI clients that support Model Context Protocol. It provides language material, schemas, examples, script checking, execution, and diagnostic explanation; it uses stdin/stdout JSON-RPC, so no extra logs may be written to stdout.

安装与配置

Installation and Configuration

安装全局 .NET 工具:

Install the global .NET tool:

dotnet tool install --global AuroraScript.Mcp --version 4.0.0

在 Codex 中添加 MCP 服务:

Add the MCP server in Codex:

codex mcp add aurora-script -- aurora-mcp

也可以在 Codex 配置中写入以下内容。Windows 配置通常位于 %USERPROFILE%\.codex\config.toml;macOS/Linux 通常位于 ~/.codex/config.toml

You can also write the following in Codex configuration. The usual Windows path is %USERPROFILE%\.codex\config.toml; the usual macOS/Linux path is ~/.codex/config.toml.

[mcp_servers.aurora-script]
type = "stdio"
command = "aurora-mcp"
startup_timeout_sec = 10
tool_timeout_sec = 60
enabled = true

本地发布的可执行文件应使用绝对路径,并为其设置明确的 cwd

A locally published executable should use an absolute path and an explicit cwd.

[mcp_servers.aurora-script]
type = "stdio"
command = "D:\\mcp\\AuroraScript.Mcp.exe"
cwd = "D:\\mcp"
enabled = true

推荐工作流

Recommended Workflow

  1. 先读取 aurora://docs/script-best-practicesaurora://schema/runtime-api
  2. 使用 aurora_search_runtime_apiaurora_get_runtime_api,不要猜测 API 名称。
  3. 生成后使用 aurora_check_scriptaurora_check_file 检查。
  4. 需要结果、stdout 或 stderr 时再使用运行工具。
  5. aurora_validate_best_practices 查找 AI 生成脚本的常见坏模式。
  1. Read aurora://docs/script-best-practices and aurora://schema/runtime-api first.
  2. Use aurora_search_runtime_api or aurora_get_runtime_api instead of guessing API names.
  3. Check generated code with aurora_check_script or aurora_check_file.
  4. Use a run tool only when a result, stdout, or stderr is needed.
  5. Use aurora_validate_best_practices to find common poor patterns in AI-authored scripts.

资源

Resources

服务内置以下稳定 URI:

The server embeds the following stable URIs:

  • aurora://docs/ai
  • aurora://docs/script-best-practices
  • aurora://docs/language
  • aurora://docs/performance
  • aurora://docs/host-integration
  • aurora://schema/ebnf
  • aurora://schema/features
  • aurora://schema/runtime-api
  • aurora://schema/host-api
  • aurora://examples/manifest

资源列表可通过 MCP 的 resources/list 发现,内容可通过 resources/read 读取。

Discover resources through MCP resources/list and read their contents through resources/read.

工具参考

Tool Reference

每个工具的参数名保持英文;参数说明先给出中文,再以下方引用给出英文。

Parameter names remain in English. Parameter descriptions appear in Chinese followed by quoted English.

aurora_get_document

按 id 或资源相对路径读取语言资料。

Reads language material by id or resource-relative path.

Parameters:

  • id
    必填。文档 id 或资源相对路径;可先用 aurora_list_documents 发现。

    Required. A document id or resource-relative path; discover it with aurora_list_documents first.

Returns

文档文本和 MIME 类型。

Document text and MIME type.

{ "name": "aurora_get_document", "arguments": { "id": "script-best-practices" } }

aurora_list_documents

列出内嵌文档、schema 和示例。

Lists embedded documents, schemas, and examples.

Parameters:

  • prefix
    可选。按相对路径前缀过滤,例如 docs/schema/examples/

    Optional. Filters by a relative-path prefix such as docs/, schema/, or examples/.

Returns

包含 id、URI、路径、名称、描述和 MIME 类型的列表。

A list containing id, URI, path, name, description, and MIME type.

{ "name": "aurora_list_documents", "arguments": { "prefix": "schema/" } }

aurora_list_features

返回结构化语言特性元数据。

Returns structured language-feature metadata.

Parameters:

  • 无。

    None.

Returns

features schema 的 JSON 文本。

JSON text for the features schema.

{ "name": "aurora_list_features", "arguments": {} }

aurora_check_script

将内存源码作为完整模块或 CompileBlock 函数体编译检查,不执行。

Compile-checks in-memory source as a full module or a CompileBlock body without executing it.

Parameters:

  • source
    必填。待检查的 AuroraScript 源码。

    Required. AuroraScript source to check.

  • mode
    可选。moduleblock;缺省按模块处理。

    Optional. module or block; module mode is the default.

  • sourceName
    可选。诊断中显示的虚拟文件名。

    Optional. Virtual filename shown in diagnostics.

  • parameters
    可选。block 模式的位置参数名。

    Optional. Positional parameter names for block mode.

  • sources
    可选。按路径键控的内存依赖源码,用于 import / include

    Optional. In-memory dependency sources keyed by path for import / include.

Returns

编译是否成功和诊断集合。

Compilation success and a diagnostic collection.

{
  "name": "aurora_check_script",
  "arguments": {
    "source": "@module(TEST); export func run() { return 42; }",
    "sourceName": "main.as"
  }
}

aurora_run_script

编译并运行内存源码,适合验证单个模块、模块依赖或 CompileBlock

Compiles and runs in-memory source, suitable for a single module, module dependencies, or a CompileBlock.

Parameters:

  • source
    必填。待编译源码。

    Required. Source to compile.

  • mode
    可选。moduleblock

    Optional. module or block.

  • sourceName
    可选。虚拟文件名。

    Optional. Virtual filename.

  • moduleName
    模块模式可选。要执行的模块名,默认 TEST

    Optional in module mode. Module name to execute; defaults to TEST.

  • methodName
    模块模式可选。要调用的导出函数名,默认 run

    Optional in module mode. Exported function to invoke; defaults to run.

  • parameters
    块模式可选。CompileBlock 参数名。

    Optional in block mode. CompileBlock parameter names.

  • arguments
    可选。转换为 AuroraScript 实参的 JSON 值数组。

    Optional. Array of JSON values converted to AuroraScript arguments.

  • sources
    可选。按路径键控的内存依赖源码。

    Optional. In-memory dependency sources keyed by path.

Returns

结果、stdout、stderr、诊断和运行时错误。

Result, stdout, stderr, diagnostics, and runtime errors.

{
  "name": "aurora_run_script",
  "arguments": {
    "mode": "block",
    "source": "return left + right;",
    "parameters": ["left", "right"],
    "arguments": [20, 22]
  }
}

aurora_check_file

检查文件系统入口脚本及其依赖图,不执行。

Checks a file-system entry script and its dependency graph without executing it.

Parameters:

  • rootDirectory
    必填。文件系统 Resolver 根目录。

    Required. File-system Resolver root.

  • entryPath
    必填。相对 rootDirectory 的入口 .as 路径,或位于根目录下的绝对路径。

    Required. Entry .as path relative to rootDirectory, or an absolute path under the root.

  • extName
    可选。脚本扩展名,默认 .as

    Optional. Script extension; defaults to .as.

  • sources
    可选。以根目录相对路径为键的内存覆盖源;使用 /,且仅在解析目标位于根下时覆盖磁盘。

    Optional. In-memory overlays keyed by root-relative path; use /, and overlays win only when the resolved target lies under the root.

Returns

编译结果和诊断集合。

Compilation result and diagnostics.

{ "name": "aurora_check_file", "arguments": { "rootDirectory": "scripts", "entryPath": "main.as" } }

aurora_run_file

编译并运行文件系统入口脚本及其依赖图。

Compiles and runs a file-system entry script and its dependency graph.

Parameters:

  • rootDirectory
    必填。文件系统 Resolver 根目录。

    Required. File-system Resolver root.

  • entryPath
    必填。入口脚本路径。

    Required. Entry script path.

  • moduleName
    必填。要执行的导出模块名。

    Required. Exported module name to execute.

  • methodName
    可选。导出函数名,默认 run

    Optional. Exported function name; defaults to run.

  • arguments
    可选。JSON 实参数组。

    Optional. JSON argument array.

  • extName
    可选。脚本扩展名,默认 .as

    Optional. Script extension; defaults to .as.

  • sources
    可选。内存覆盖源。

    Optional. In-memory overlay sources.

Returns

结果、输出、诊断和运行时错误。

Result, output, diagnostics, and runtime errors.

{
  "name": "aurora_run_file",
  "arguments": { "rootDirectory": "examples/tests", "entryPath": "main.as", "moduleName": "MAIN", "methodName": "run" }
}

aurora_build_workspace

编译文件系统根目录下 Resolver 可见的全部脚本。

Compiles every Resolver-visible script below a file-system root.

Parameters:

  • rootDirectory
    必填。文件系统 Resolver 根目录。

    Required. File-system Resolver root.

  • extName
    可选。脚本扩展名,默认 .as

    Optional. Script extension; defaults to .as.

  • sources
    可选。内存覆盖源。

    Optional. In-memory overlay sources.

Returns

工作区编译结果和诊断。

Workspace compilation result and diagnostics.

{ "name": "aurora_build_workspace", "arguments": { "rootDirectory": "scripts" } }

aurora_search_runtime_api

搜索结构化脚本运行时 API 索引。

Searches the structured script runtime API index.

Parameters:

  • query
    必填。名称或文本,例如 String.trimHashMapappendLine

    Required. Name or text such as String.trim, HashMap, or appendLine.

  • limit
    可选。最大结果数,默认 20

    Optional. Maximum result count; defaults to 20.

Returns

匹配的运行时 API 条目。

Matching runtime API entries.

{ "name": "aurora_search_runtime_api", "arguments": { "query": "StringBuffer", "limit": 10 } }

aurora_get_runtime_api

按 API 路径读取一个结构化运行时条目。

Reads one structured runtime entry by API path.

Parameters:

  • path
    必填。运行时 API 路径,例如 MathArray.pushString.trimHashMap.get

    Required. Runtime API path such as Math, Array.push, String.trim, or HashMap.get.

Returns

API 条目及其签名、参数与说明。

The API entry with its signatures, parameters, and documentation.

{ "name": "aurora_get_runtime_api", "arguments": { "path": "Array.push" } }

aurora_list_examples

列出语言包 manifest 中的有效、无效或全部示例。

Lists valid, invalid, or all examples from the language-pack manifest.

Parameters:

  • kind
    可选。validinvalidall

    Optional. valid, invalid, or all.

Returns

示例清单。

Example manifest entries.

{ "name": "aurora_list_examples", "arguments": { "kind": "valid" } }

aurora_get_example

按 manifest 路径读取一个嵌入示例。

Reads an embedded example by manifest path.

Parameters:

  • path
    必填。示例路径,例如 valid/templates.asinvalid/const-assignment.as

    Required. Example path such as valid/templates.as or invalid/const-assignment.as.

Returns

示例源文本和 MIME 类型。

Example source text and MIME type.

{ "name": "aurora_get_example", "arguments": { "path": "valid/templates.as" } }

aurora_validate_best_practices

检查 AI 生成脚本中的已知写法问题。

Checks AI-authored source for known authoring-pattern issues.

Parameters:

  • source
    必填。要检查的源码。

    Required. Source to check.

  • mode
    可选。moduleblock

    Optional. module or block.

Returns

最佳实践警告集合。

A collection of best-practice warnings.

{
  "name": "aurora_validate_best_practices",
  "arguments": { "mode": "block", "source": "for (var i = 0; i < items.length; i++) { total += items[i]; } return total;" }
}

aurora_explain_diagnostic

解释常见 AuroraScript 编译诊断及其可能修复方式。

Explains common AuroraScript compiler diagnostics and likely fixes.

Parameters:

  • message
    必填。编译器诊断消息。

    Required. Compiler diagnostic message.

Returns

诊断含义与建议修复。

Diagnostic meaning and suggested fixes.

{ "name": "aurora_explain_diagnostic", "arguments": { "message": "Cannot assign to const value." } }

文件系统覆盖规则

File-system Overlay Rules

aurora_check_fileaurora_run_fileaurora_build_workspace 会把可选内存 sources 放在磁盘 Resolver 之前。键会用 / 规范化并相对 rootDirectory 解析;较早的 Resolver 优先,但只有解析后的目标仍在内存 root 下时,内存覆盖才会命中。不同协议或不相交 root 不会相互覆盖。

aurora_check_file, aurora_run_file, and aurora_build_workspace place optional in-memory sources ahead of the disk Resolver. Keys are normalized with / and resolved relative to rootDirectory; earlier resolvers win, but an overlay only hits when the resolved target remains under the memory root. Different protocols or non-overlapping roots cannot override one another.

Clone this wiki locally