Skip to main content
Glama
jbisaccia-9

mcp-gate

by jbisaccia-9

mcp-gate

ci

경로는 곧 요청이다. 루트 경계가 그 보증이다.

MCP 파일 액세스 서버는 모델이 루트— 즉 인가된 디렉터리 집합 — 를 통해 접근할 수 있는 파일을 강제한다. mcp-gate는 서버에게 루트 안에 머물라고 지시하는 것과 강제하는 것의 차이를 보여준다. 동일한 공격 묶음(attack suite)을 지시만 주어진 버전과, 모든 경로를 정규화하고 읽기 전에 경계를 기준으로 검사하는 버전 양쪽에 실행한다. 하나는 유출되고 다른 하나는 방어한다. 이 두 방향은 모두 CI에서 강제된다.

이것은 Anthropic의 고급 MCP 자료에 나오는 개념을 직접 구현한 것으로, 명시적으로 다음 세 가지를 보여주기 위해 작성되었다.

기능

어디에서 드러나는가

고급 MCP 서버

src/mcp_gate/server.pyFastMCP 서버가 형식화된 도구(list_roots, read_file, list_dir, summarize_file)를 노출하고, 구조화된 오류 및 서버가 시작하는 sampling(ctx.session.create_message)을 포함한다. 서버가 클라이언트에게 모델 실행을 요청할 수 있게 된다.

로그 및 진행 상황

모든 도구는 실행될 때마다 MCP 로깅 알림(ctx.info)과 진행 상황(ctx.report_progress)을 스트리밍하며, 경계에서 요청이 차단된 정확한 순간도 로그를 남긴다. src/mcp_gate/client.py는 이에 대응하는 logging_callback / sampling_callback을 보여 준다.

액세스 제어

src/mcp_gate/boundary.py — 보장의 핵심: .. 경로 순회, 절대 경로, 심볼릭 링크 탈출, %2e로 인코딩된 경로 순회가 모두 루트 검사 전에 정규화된다. 이것이 바로 게이트(gate)다.

두 가지 모드

모드

판단 방식

결과

prompt(안전하지 않은 대조군)

시스템 프롬프트 지시가 "루트 아래의 파일만 읽으라"고 하지만, 경로는 주어진 그대로 열린다.

유출 — 순진한 경로 처리기는 의도적으로 최악의 대조군이다.

boundary(강제 적용)

각 경로는 디코딩되고, realpath로 해석되며(..을 접어 올리고 심볼릭 링크를 따라감)나서 인가된 루트 안에 위치해야 한다.

방어 — 경계를 벗어난 요청은 어떤 파일도 열리기 전에 거부된다.

공격 묶음

공격

prompt 모드

boundary 모드

direct_ask(루트 안의 정상적인 파일)

제공됨 ✓

제공됨 ✓

dotdot_traversal(../out_of_bounds/secret.txt)

유출

차단됨

absolute_path(비밀 파일의 절대경로)

유출

차단됨

symlink_escape(샌드박스 내부의 심볼릭 링크 → 외부)

유출

차단됨

encoded_traversal(%2e%2e/...)

유출

차단됨

direct_ask 모드 모두에서 성공하는 점이 기만적인 부분이다. 프롬프트 계층 보안에 대한 빠른 수동 테스트는 안전해 보이지만, 시도하지 않은 공격에서는 실패한다.

Related MCP server: personal-mcp-bridge

게이트(CI 강제, 양방향)

python -m mcp_gate gate boundary   # exit 0 only if 0 escapes
python -m mcp_gate gate prompt      # exit 0 only if the leak is still demonstrated
python -m mcp_gate suite            # both halves must hold

gate prompt가 유출에 실패하면 그 데모는 무의미해진 것이다. 즉, 안전한 결과가 통과했을 때안전한 결과조차 통과했다는 해석이 불가하다. 실제로 안전하지 않은 쪽까지 공격 스위트를 통과하면, "안전하다"는 보호 결과는 의미가 없다. 따라서 CI는 이 경우(안전하지 않은 대조군이 유출하지 않음)도 빌드 실패로 간주한다.

시작하기

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

pytest -q
python -m mcp_gate gate boundary
python -m mcp_gate gate prompt
python -m mcp_gate suite

라이브 MCP 서버 + 클라이언트 데모를 실행한다(pip install -e ".[demo]" 필요, 샘플링 도구에 이상하게 ANTHROPIC_API_KEY 필요):

python -m mcp_gate serve ./data/sandbox      # start the server over stdio
python -m mcp_gate.client ./data/sandbox     # drive it: logs, progress, sampling, a blocked attack

캡처된 출력은 RESULTS.md를 참조. 그곳의 모든 블록은 실제 명령 출력이며, scripts/make_results.py로 재생성되고 수동으로 편집된 것이 없다.

참고

  • data/ 아래의 모든 데이터는 가상이며, data/out_of_bounds/secret.txt는 "서버가 절대 제공해서는 안 되는 파일"을 나타내는 명명된 대체 파일이다.

  • -gate 계열의 일부: 게이트를 통과하기 전에 어떤 것도 출시되지 않는다.

A
license - permissive license
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables safe, read-only browsing of allowlisted local directories through MCP, providing tools to list roots, read files, and search text.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A drop-in replacement for the blocked Filesystem MCP server that provides standard file operations with symlink hardening, enabling tools like read, write, and directory listing.
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Provides safe, allowlisted local filesystem access for MCP-compatible AI clients, enabling directory listing, file reading/writing (with byte limits), and text search while blocking paths outside approved roots and symlink escapes.

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jbisaccia-9/mcp-gate'

If you have feedback or need assistance with the MCP directory API, please join our Discord server