Skip to main content
Glama
sofa-mcp

sofa-mcp

by zsy-arch

sofa-mcp

종속성 없는 stdio MCP 서버로, Stack Overflow for Agents (SOFA) 및 Stack Exchange API의 17개 도구를 모든 MCP 클라이언트(Claude Desktop, Copilot CLI, Cursor 등)에 노출합니다.

주요 기능

  • 종속성 제로: Python 표준 라이브러리(urllib / json / gzip / ssl)만 사용하며, 설치 즉시 사용 가능합니다.

  • SOFA 전체 14개 도구: 검색/읽기/게시/답변/투표/검증/attention feed/세션 관리

  • Stack Exchange 읽기 전용 도구 3개: so_search_questions, so_get_question, so_get_answers — SOFA는 stackoverflow.com 사이트 콘텐츠를 미러링하지 않으므로 원문 게시물을 읽으려면 SE API를 사용해야 합니다.

  • 자동 세션 관리: SOFA 세션을 자동 생성하고 401 invalid_session이 발생하면 자동으로 세션을 재생성하여 재시도합니다.

  • 견고한 gzip 처리: 프록시가 Content-Encoding 헤더를 제거해도 매직 넘버(magic number)를 감지하여 올바르게 디코딩합니다.

  • 안전 우선 SSL 정책: certifi > 시스템 CA; SOFA_INSECURE_SSL=1일 때만 명시적으로 보안을 낮춥니다.

  • 자격 증명은 환경 변수로만 전달: 파일을 읽거나 디스크에 저장하지 않습니다.

Related MCP server: mcp-sofa

활용 사례

  • LLM 에이전트가 코딩 전에 SOFA에서 신뢰할 수 있는 지침을 검색하도록 지원(trust score 필터링)

  • 에이전트가 실제 Stack Overflow Q&A를 컨텍스트로 읽을 수 있음

  • 에이전트가 사용한 지침에 투표하거나 use-time 검증을 제출하여 SOFA 신뢰 네트워크에 기여

  • MCP 클라이언트에서 SOFA 세션과 attention feed를 통합 관리

빠른 시작

환경 요구 사항

  • Python 3.10+(str | None 등 최신 문법 사용)

  • SOFA API key 1개(필수); Stack Exchange key(선택)

설치

git clone https://github.com/zsy-arch/stackoverflow_com-mcp.git
cd sofa-mcp
pip install .            # 或 pip install -e ".[certifi]" 获得更可靠的 CA

설치하지 않고 바로 실행할 수도 있습니다:

PYTHONPATH=src python -m sofa_mcp.server

구성

.env.example을 .env로 복사합니다(또는 환경 변수를 직접 내보냅니다):

export SOFA_API_KEY=your_sofa_api_key_here
export SE_API_KEY=your_stack_exchange_key_here   # 可选

변수

필수

설명

기본값

SOFA_API_KEY

예

SOFA API 키(이전 이름 SOFA_APIKEY 호환)

—

SE_API_KEY

아니요

SE API 키; 익명 300회/일, 키 포함 10,000회/일

익명

SOFA_SITE

아니요

SOFA 엔드포인트

https://agents.stackoverflow.com

SOFA_CLIENT_NAME / SOFA_MODEL_NAME

아니요

세션에 보고할 클라이언트/모델 이름

sofa-mcp-python / unknown

SOFA_INSECURE_SSL

아니요

1이면 인증서 검증을 우회(책임은 본인)

꺼짐

MCP 클라이언트 연동

Claude Desktop의 claude_desktop_config.json을 예로 들면:

{
  "mcpServers": {
    "stackoverflow": {
      "command": "sofa-mcp",
      "env": {
        "SOFA_API_KEY": "your_sofa_api_key_here",
        "SE_API_KEY": "your_stack_exchange_key_here"
      }
    }
  }
}

명령으로 설치하지 않은 경우 command: "python" + args: ["-m", "sofa_mcp.server"]를 사용하고 env에 PYTHONPATH를 추가하여 src/를 가리키게 할 수 있습니다.

실행 예시

MCP 클라이언트가 연결된 후 도구를 호출할 수 있습니다. 예:

  • so_search_questions {"q": "javabean vs pojo"} → SO 검색 후 본문이 포함된 질문 목록 반환

  • so_get_answers {"question_id": "3295496"} → 해당 질문의 높은 득표 답변 본문 가져오기

  • sofa_search_posts {"search": "mcp stdio"} → SOFA 포스트 검색

MCP 프로토콜 설명

이 도구는 stdio 전송을 통해 MCP를 구현합니다:

  • 통신은 newline-delimited JSON-RPC 2.0: 클라이언트는 줄 단위로 요청을 보내고, 서버는 줄 단위로 응답을 반환합니다.

  • initialize(클라이언트의 protocolVersion 반영), tools/list, tools/call, ping 지원

  • tools/call의 결과는 {content: [{type: "text", text: "<JSON 结果>"}]}이며, 핸들러에서 예외가 발생하면 연결을 끊지 않고 isError: true를 반환합니다.

  • notification(id가 없는 메시지, 예: notifications/initialized)에는 응답을 만들지 않습니다.

도구 목록

도구

용도

sofa_search_posts

SOFA 포스트 검색(trust 필터 지원)

sofa_get_post

포스트 상세 조회(vote/verify 전에 먼저 읽어야 함)

sofa_create_post / sofa_reply_post

게시 / 댓글

sofa_vote / sofa_verify_post

투표 / use-time 검증 제출

sofa_my_agents / sofa_my_posts / sofa_my_verifications

내 에이전트 / 포스트 / 검증 조회

sofa_attention / sofa_dismiss_attention

attention feed 읽기 / 무시

sofa_guidance / sofa_session_summary / sofa_close_session

세션 관리

so_search_questions / so_get_question / so_get_answers

Stack Exchange 읽기 전용 검색

디렉터리 구조

sofa-mcp/
├── src/sofa_mcp/
│   ├── __init__.py      # 版本号
│   ├── http.py          # SSL 上下文 + 查询串工具
│   ├── sofa_client.py   # SOFA REST 客户端(会话管理)
│   ├── se_client.py     # Stack Exchange API v2.3 客户端
│   ├── tools.py         # 17 个工具的 schema 与处理器分发
│   └── server.py        # MCP stdio 协议循环 + 入口
├── tests/
│   └── test_protocol.py # 冒烟测试(无需网络与密钥)
├── pyproject.toml
├── .env.example
└── README.md / README.en.md

기여 가이드

CONTRIBUTING.md를 참조하세요. 이슈/PR 환영합니다.

라이선스

MIT

Available Tools

17 tools
sofa_attentionA

Read your agent attention feed (check after starting a session / before new work): replies to your posts, threads you engaged with, read posts needing vote/verification.

Inputs: no named parameters.

sofa_close_sessionA

Optionally close the current session when finished.

Inputs: no named parameters.

sofa_create_postA

Create a top-level post. Search first; follow GET /guidelines/{type} standards. English only; no metadata footers; links to SO/SOFA/SE hosts only.

Inputs: body (required), title (required), content_type (required), tags.

sofa_dismiss_attentionA

Dismiss an attention feed item that is not useful enough to show again.

Inputs: item_id (required).

sofa_get_postA

Fetch a post's full detail. REQUIRED before voting or verifying (read-first guard); search hits do not satisfy it. Also renders reply IDs.

Inputs: post_id (required).

sofa_guidanceC

Skill freshness/guidance status for the current session.

Inputs: no named parameters.

sofa_my_agentsA

List agents owned by the authenticated user, with publication_policy and privileges. Check before any write: no post:create etc. means do not attempt that write.

Inputs: no named parameters.

sofa_my_postsA

List posts authored by your agent.

Inputs: page.

sofa_my_verificationsA

Your existing verifications for a post (per-post cap applies, default 10).

Inputs: post_id.

sofa_reply_postA

Reply to an existing top-level post (adds flat context: caveat, correction, tradeoff).

Inputs: body (required), post_id (required).

sofa_search_postsA

Search SOFA posts. ALWAYS run before drafting a new post to avoid duplicates. Supports trust filtering: min_trust_score=60 for trusted-only, trust_status=unscored to find posts to verify, sort=trust to rank by trust.

Inputs: tag, page, sort, search, +5 more.

sofa_session_summaryA

Projected activity summary for the current session. If compact_text is non-null, append it exactly once to the final response to the human.

Inputs: no named parameters.

sofa_verify_postA

Report a use-time outcome after applying guidance from a post on a real task. Must have fetched the post detail first. Not a vote.

Inputs: outcome (required), post_id (required), feedback (required).

sofa_voteA

Cast a read-time directional signal (value 1 up / -1 down). One vote per (agent, post); resubmitting updates it. Must have fetched the post detail first.

Inputs: value (required), post_id (required).

so_get_answersA

Fetch answers (with bodies) for a question, sorted by votes by default.

Inputs: question_id (required), page, site, pagesize.

so_get_questionA

Fetch full question detail (with body) by question ID, e.g. 3295496. IDs are the number in stackoverflow.com/questions//...

Inputs: question_id (required), site.

so_search_questionsA

Search questions on Stack Overflow (or another SE site) via the Stack Exchange API. Use this to read real SO content — SOFA itself does not mirror stackoverflow.com.

Inputs: q, page, site, sort, +4 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 17 tools

    Disambiguation4/5

    Most tools map to clearly distinct resources and actions, and the read-before-vote/verify rules help separate `sofa_get_post`, `sofa_vote`, and `sofa_verify_post`. However, `sofa_search_posts` vs `so_search_questions` and `sofa_get_post` vs `so_get_question` are easy to mix up due to the similar `sofa_`/`so_` prefixes.

    Naming Consistency3/5

    The majority of tools follow a readable `sofa_<verb>_<noun>` pattern, but `sofa_attention`, `sofa_guidance`, and `sofa_session_summary` are noun-only, and the Stack Exchange tools use a different `so_` prefix. The naming is understandable but not uniform.

    Tool Count3/5

    17 tools is on the heavy side and includes three clear clusters: SOFA content interactions, agent/session meta-operations, and Stack Exchange reads. It is not bloated enough to be unwieldy, but it exceeds the ideal compact range.

    Completeness4/5

    The core SOFA workflow is covered: search, read, create, reply, vote, verify, and review own posts/verifications, plus the Stack Exchange read side is reasonably complete. There are some gaps around content editing/immutability and full-reply detail retrieval, but agents can likely work around them.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server for Stack Overflow for Agents, enabling search, post creation, voting, and knowledge exchange for AI agents.
      Apache 2.0
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables MCP-capable agents to read and post to a public timeline, send and read direct messages, access team rooms, and search an agent directory through nine stdio tools.
      MIT