无头测试
- 作者仓库星标 0
- 作者仓库 skills-registry
- 领域
- 人工智能
- 作者声明的智能体
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 运行环境证据
- 未执行;当前没有隔离运行测试证据
- 作者 / 版本 / 许可证
- @tomevault-io · 未声明许可证
- 上下文用量评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部接口密钥
- 需要 · Anthropic
- 兼容的系统
- macOS · Linux · Windows
- 运行环境要求
- Node.js
- 检测到的文件与系统行为
-
- 只读
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
需要注意: 未声明工具权限范围;实际权限由运行环境决定。
# MCP Headless Test Pipeline
## Purpose
Validate the Ariadne MCP server by running it with Claude Code in headless mode (`claude -p`). This tests the real user experience rather than just programmatic MCP client behavior.
## Prerequisites
Before running tests, ensure:
1. **Claude Code CLI** is installed and configured
2. **API key** is set (either `ANTHROPIC_API_KEY` env var or Claude's configured key)
3. **MCP package is built**:
```bash
npm run build -w packages/mcp
```
## Running the Tests
### Quick Run
```bash
cd packages/mcp
./tests/claude-headless-test.sh
```
### Verbose Mode (for debugging)
```bash
./tests/claude-headless-test.sh --verbose
```
## Test Scenarios
The script runs 3 tests:
| Test | Name | What It Validates |
| ---- | ----------------- | ----------------------------------------------------- |
| 1 | Tool Discovery | Claude can see the `list_entrypoints` tool |
| 2 | Tool Invocation | Tool runs successfully on fixture code |
| 3 | Filtered Analysis | File/folder filtering parameters work |
## Interpreting Results
### Success Output
```text
========================================
Ariadne MCP - Claude Headless Tests
========================================
[INFO] Checking prerequisites...
[INFO] All prerequisites met.
[INFO] Test 1: Tool Discovery
[INFO] Checking if Claude can see the list_entrypoints tool...
[INFO] PASS: Tool 'list_entrypoints' discovered
[INFO] Test 2: Tool Invocation
[INFO] Running list_entrypoints on fixture code...
[INFO] - Found 'entry point' in output
[INFO] PASS: Tool invocation succeeded
[INFO] Test 3: Filtered Analysis
[INFO] Testing file/folder filtering parameters...
[INFO] PASS: Filtered analysis completed
========================================
Test Summary
========================================
Total: 3
Passed: 3
Failed: 0
[INFO] All tests passed!
```
### Failure Indicators
| Indicator | Meaning | Action |
| -------------------------------------- | -------------------------------------------- | ----------------------------------------------------- |
| `Claude Code CLI not found` | `claude` command not in PATH | Install Claude Code CLI |
| `MCP server not built` | Missing `dist/server.js` | Run `npm run build -w packages/mcp` |
| `Tool 'list_entrypoints' not found` | Claude didn't discover the MCP tool | Check MCP config, server logs |
| `Tool invocation did not produce...` | Tool ran but output unexpected | Check if fixtures exist, review Claude's response |
| `FAIL: Filtered analysis...` | Folder filtering parameter not working | Check tool schema, parameter handling |
## Verifying Correctness
### Test 1: Tool Discovery
**Expected behavior**: Claude should list `list_entrypoints` when asked about available tools.
**Manual verification**:
```bash
claude -p "What MCP tools do you have?" \
--mcp-config ./packages/mcp/tests/mcp-test-config.json \
--output-format json
```
Look for output containing:
- Tool name: `list_entrypoints`
- Description mentioning "entry point" and "call tree"
### Test 2: Tool Invocation
**Expected behavior**: Claude should successfully invoke the tool and return analysis results.
**Manual verification**:
```bash
claude -p "Use list_entrypoints to analyze the codebase" \
--mcp-config ./packages/mcp/tests/mcp-test-config.json
```
Valid output should contain:
- "Entry Points" header
- Function signatures (e.g., `function_name(...): return_type`)
- Tree size indicators (e.g., `-- N functions`)
- File locations (e.g., `Location: ...`)
- Total count (e.g., `Total: X entry points`)
### Test 3: Filtered Analysis
**Expected behavior**: Tool accepts `folders` parameter and analyzes only specified directories.
**Manual verification**:
```bash
claude -p "Use list_entrypoints with folders=['functions']" \
--mcp-config ./packages/mcp/tests/mcp-test-config.json
```
Valid output: Should show entry points only from the `functions/` subdirectory of the fixtures.
## Test Configuration
The tests use `packages/mcp/tests/mcp-test-config.json`:
```json
{
"mcpServers": {
"ariadne": {
"type": "stdio",
"command": "node",
"args": ["./packages/mcp/dist/server.js"],
"env": {
"PROJECT_PATH": "./packages/core/tests/fixtures/typescript/code"
}
}
}
}
```
This points to TypeScript fixtures in `packages/core/tests/fixtures/typescript/code/` for deterministic, reproducible tests.
## Server Lifecycle Notes
**Important**: The MCP server process stays alive across tool calls within a session, BUT each tool call creates a fresh `Project` instance and re-indexes the codebase. This is intentional to support scoped analysis (file/folder filtering).
**Performance implication**: Large codebases may take 2+ seconds per tool call due to re-indexing.
## Troubleshooting
### Claude hangs or times out
- Check `ANTHROPIC_API_KEY` is valid
- Try with `--verbose` flag to see debug output
- Ensure network connectivity to Anthropic API
### Tool not discovered
1. Verify MCP config path is correct
2. Check server.js exists: `ls packages/mcp/dist/server.js`
3. Test server directly:
```bash
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | \
PROJECT_PATH=. node packages/mcp/dist/server.js
```
### Unexpected tool output
1. Check fixtures exist: `ls packages/core/tests/fixtures/typescript/code/`
2. Test with E2E tests first: `npm test -w packages/mcp`
3. Review server stderr for errors (use `--verbose`)
## Related Files
| File | Purpose |
| ----------------------------------------- | -------------------------------- |
| `packages/mcp/tests/claude-headless-test.sh` | Test runner script |
| `packages/mcp/tests/mcp-test-config.json` | MCP server configuration |
| `packages/mcp/src/start_server.ts` | Server implementation |
| `packages/mcp/src/list_entrypoints.e2e.test.ts` | Programmatic E2E tests |
---
> Source: [CRJFisher/ariadne](https://github.com/CRJFisher/ariadne) — distributed by [TomeVault](https://tomevault.io).
<!-- tomevault:4.0:skill_md:2026-05-23 -->
章节与文件索引
按说明文件中的顺序排列。
目的
先决条件
测试场景
故障指示器
测试 1:工具发现
文件/命令 -> claude -p · ANTHROPIC_API_KEY · list_entrypoints · Claude Code CLI not found · MCP server not built · dist/server.js · npm run build -w packages/mcp · Tool 'list_entrypoints' not found
内容校验值 -> 4f7c06f24968
当前原文的自动摘译,尚未人工审校。
目的
通过在无头模式下使用 Claude Code 运行 Ariadne MCP 服务器来验证该服务器 (
claude -p)。这测试了真实的用户体验,而不仅仅是编程式的 MCP 客户端行为。先决条件
在运行测试之前,请确保: Claude Code CLI 已安装,并且配置的 API 密钥已设置(
ANTHROPIC_API_KEYenv var 或 Claude 的配置密钥)已构建 MCP 包:测试场景
该脚本运行 3 个测试:测试 · 名称 · 验证什么 1 · 工具发现 · Claude 可以看到
list_entrypoints工具 2 · 工具调用 · 工具在夹具代码上成功运行 3 · 过滤分析 · 文件/文件夹过滤参数工作故障指示器
指示器 · 含义 · 操作
Claude Code CLI not found·claude命令不在 PATH 中 · 安装 Claude Code CLIMCP server not built· 缺少dist/server.js· 运行npm run build -w packages/mcpTool 'list_entrypoints' not found· Claude 没有发现 MCP 工具 · 检查 MCP 配置、服务器日志Tool invocation did not produce...· 工具已运行但输出意外 · 检查是否固定装置存在,查看克劳德的回应测试 1:工具发现
预期行为:当被问及可用工具时,Claude 应列出
list_entrypoints。手动验证:查找包含以下内容的输出:工具名称:list_entrypoints提及“入口点”和“调用树”的描述