🎃 Add "Copy as cURL" to an audit log entry to replay the MCP tool call
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- bash, typescript
- Lĩnh vực
- documentation, frontend, testing
Hướng nghiên cứu
Start with the expanded audit row in packages/frontend/src/app/logs/page.tsx (around lines 382-419), then read the origin and clipboard logic in mcp-server/[id]/page.tsx (lines 98-102 and 210-245) that should move into lib/. Check the stored input in packages/backend/src/mcp-server/dynamic-mcp-tools.ts (around 412-421) to confirm what the arguments contain. Done means a pure buildToolCallCurl in lib/curl.ts emits the heredoc with a placeholder credential, the button is disabled for null mcpServer and truncated inputs, and a Playwright test in tests/e2e asserts the copied text.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Part of the October Challenge #997.
Why
When a tool call fails, the first step in debugging is to run it again outside the AI client. The log row already has the tool name, the arguments and the MCP server it came through, but rebuilding a valid MCP JSON-RPC request by hand (headers, protocol version, envelope) is slow and easy to get wrong. Browser DevTools, Postman and Insomnia all have "Copy as cURL". This issue adds that button to each entry on the Audit Log page.
What the log actually stores: tool_invocations.input holds the MCP tool arguments, saved before env vars are injected (dynamic-mcp-tools.ts:412-421). It does not hold the upstream HTTP request (URL, headers, body sent to the vendor API). So this feature replays the MCP tools/call against AnythingMCP. It does not replay the upstream API call. That is deliberate: upstream requests carry the connector's credentials.
Self-hosted vs Cloud
- Self-hosted: enabled in Community and Business. No
ee/code. - Cloud (
DEPLOYMENT_MODE=cloud): enabled. The command targetshttps://cloud.anythingmcp.com/mcp/<serverId>, which the user can already reach with their own credentials. Nothing instance-wide is exposed, and the button is client-side only with no new endpoint. - Who can use it: any role that can see
/logstoday. The command only contains data already shown in the expanded row, plus a placeholder for the credential.
What to build
- A "Copy as cURL" button in the expanded row (
logs/page.tsx:382-419), next to the User/Server meta line. - Put a pure builder in
packages/frontend/src/lib/curl.ts:buildToolCallCurl({ origin, serverId, toolName, args, authMode }). Output:
The quoted heredoc means no shell escaping is needed for the JSON. Before you finalize the headers, check that a barecurl -sS -X POST "https://host/mcp/<serverId>" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -H "MCP-Protocol-Version: 2025-06-18" \ -H "X-API-Key: $AMCP_MCP_API_KEY" \ --data-binary @- <<'JSON' {"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"<tool>","arguments":{...}}} JSONtools/call(noinitialize) is accepted by the stateless per-server endpoint on a local instance. If it is not, emit aninitializecall first and say so in a comment. - The credential is always a placeholder env var. Never put a real secret in the command. The auth header follows
MCP_AUTH_MODEfromserver.info():legacy/bothgivesX-API-Key: $AMCP_MCP_API_KEY(per-usermcp_…keys work in every mode on/mcp/<id>, seemcp-combined-auth.guard.ts:64), andoauth2givesAuthorization: Bearer $AMCP_ACCESS_TOKEN. Never insert the dashboard session token (amcp_tokenin localStorage). The MCP guard accepts app JWTs (mcp-combined-auth.guard.ts:89-100), so pasting one would leak a full-account credential into shell history and tickets. - Origin: reuse the logic in
mcp-server/[id]/page.tsx:98-102(localhost→:4000, otherwisewindow.location.origin). Move it intolib/rather than copying it. - Disable the button, with a tooltip explaining why, when:
log.mcpServeris null. The call came through the shared/mcpendpoint, which on Cloud only exposes the eightanythingmcp_*tools (shared-toolset.ts:26-55), so a direct call by tool name would not work there.log.input._amcp_truncatedis present. The stored arguments are an excerpt (bound-payload.ts:16), so a replay would not be faithful.
- Reuse the clipboard fallback from
mcp-server/[id]/page.tsx:210-245(it handles plain-HTTP LAN installs). Moving it intolib/clipboard.tsis welcome.
Where to look
packages/frontend/src/app/logs/page.tsx:382-419: expanded row (log.input,log.mcpServer,log.tool.name).packages/backend/src/audit/audit.service.ts:204-224: fields returned per row (mcpServer.id/slug,tool.name).packages/backend/src/mcp-server/dynamic-mcp-tools.ts:412-421:input: params(pre-env-injection args).packages/backend/src/mcp-server/mcp-endpoint.controller.ts:1042-1048: stateless handler,legacy: 'stateless'.packages/frontend/src/lib/api.ts:964-977:server.info()→mcpAuthMode.
Acceptance criteria
- The copied command runs against a local instance with a real key exported as
AMCP_MCP_API_KEYand returns the tool result (describe the manual check in the PR). - Args containing
',",$, backticks and newlines survive unchanged (heredoc). - No token, key or cookie value ever appears in the output. The test asserts the placeholder is present.
- The button is disabled for shared-endpoint rows and truncated inputs.
- Playwright test in
packages/frontend/tests/e2e/(stub/api/audit/invocationsand/health/server-infolikeredesign.spec.ts, grant clipboard permission, assert the copied text). Run withcd packages/frontend && npm run test:e2e. - Short "Replay a tool call" note added to
docs/api-reference.mdnear the Audit section (line 219).
Out of scope
- Replaying the upstream vendor HTTP request (it is not stored, and it carries credentials).
- PowerShell/HTTPie variants, HAR export.
- A "Run again" button that executes from the browser.
Size
S (a few hours)
How to claim
Comment "I'd like to work on this" and we'll assign you. Rules in #997.
- Ngôn ngữ chính
- TypeScript
- Star
- 856
- Fork
- 82
- Merge trung bình
- 6 giờ 49 phút
- Pull request đã merge (30 ngày)
- 152
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của HelpCode-ai/anythingmcp
-
Docs: document all SMTP_* and other undocumented env vars for self-hostingCó thể đã có người làm @notlakshitha đã nhận hôm nay. Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
HelpCode-ai/anythingmcp#1049 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue hacktoberfest
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 70/100
HelpCode-ai/anythingmcp#996 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
good first issue hacktoberfest
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
HelpCode-ai/anythingmcp#995 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement good first issue hacktoberfest help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
HelpCode-ai/anythingmcp#982 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Upload the new social previewCó thể đã có người làm @helpcodeai đã nhận hôm nay. Đang mở
HelpCode-ai/anythingmcp#1087 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của HelpCode-ai/anythingmcp
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AvaProtocol/ava-sdk-js#276 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
useFragment does not require `variables` when the fragment's variables type has required fieldsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
apollographql/apollo-client#13493 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Custom hosts written as trailing-dot FQDNs (`host.local.`) aren't detected as local backendsCó thể đã có người làm @roboomp đã nhận hôm nay. Đang mởbug prio:p2 providers triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
can1357/oh-my-pi#15798 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
code-yeongyu/oh-my-openagent#10172 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
PDFCraftTool/pdfcraft#189 ·