Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Building, Securing, and Auditing MCP Servers: A Developer Workflow

说明与用途

作者介绍了MCP服务器的开发工作流程:构建轻量级服务器,在发现阶段实施严格的客户端工具范围限制,并在CI/CD中使用mcp-audit扫描器检测shell执行或密钥泄露等安全漏洞。

问题

Exposing AI agent tools via Model Context Protocol (MCP) creates security risks if tools are not properly scoped, authenticated, or audited for dangerous capabilities like shell execution or data leakage.

结果

The author demonstrates a complete lifecycle for MCP server development: building lightweight servers, implementing strict per-client scoping to prevent unauthorized tool access, and using an automated scanner to enforce security standards in CI/CD.

工作流

  • Implement MCP transport using standard JSON-RPC 2.0 (e.g., streamable HTTP) without heavy frameworks.
  • Isolate tool logic (search, ranking) as pure functions for easier testing and separation from protocol boilerplate.
  • For sensitive data, enforce scope at discovery: configure clients with allowed tools and write permissions.
  • Filter the tools/list response based on client identity so unauthorized clients never see restricted tools.
  • Implement authentication (bearer keys) and maintain an append-only audit log for all tool calls.
  • Run mcp-audit scanner in CI/CD to check for dangerous patterns (shell exec, exposed secrets, SSRF risks).
  • Fail the build if critical or high-severity findings are detected.

证据

Scope is enforced at discovery, not just at call time. Clients are configured in a secret as JSON... When a client calls tools/list, the server only advertises the tools that client is scoped for.

来源

mcp-audit... runs 18 rules over that surface... The process exits non-zero when any finding reaches the --fail-on threshold... so a bad audit breaks the build.

来源

  • 记录日期: 2026-09-09T21:45:50.790Z