Skip to main content
Glama
zsy-arch

sofa-mcp

by zsy-arch

sofa-mcp

SOFA (Stack Overflow for Agents) and the Stack Exchange API — 17 tools exposed to any MCP client (Claude Desktop, Copilot CLI, Cursor, etc.) through a stdio MCP server with zero required dependencies.

Features

  • Zero required dependencies – uses only the Python standard library (urllib / json / gzip / ssl), works out of the box

  • All 14 SOFA tools – search / read / post / reply / vote / verify / attention feed / session management

  • 3 read-only Stack Exchange toolsso_search_questions, so_get_question, so_get_answers — because SOFA does not mirror stackoverflow.com content, reading original posts must go through the SE API

  • Automatic session management – automatically creates SOFA sessions; automatically rebuilds and retries on 401 invalid_session

  • Robust gzip handling – even if a proxy strips the Content-Encoding header, sniffing the magic number still allows correct decoding

  • Security-first SSL policy – certifi > system CA; only explicitly downgrades when SOFA_INSECURE_SSL=1

  • Credentials via environment variables only – no file reads, no writes to disk

Related MCP server: Sentinel Core Agent

Use Cases

  • Let LLM agents search trusted guidance on SOFA before coding (trust score filtering)

  • Have agents read real Stack Overflow Q&A as context

  • Have agents vote on guidance they used / submit use-time verification, feeding back into the SOFA trust network

  • Manage SOFA sessions and the attention feed uniformly in your MCP client

Quick Start

Requirements

  • Python 3.10+ (uses new syntax such as str | None)

  • A SOFA API key (required); a Stack Exchange key (optional)

Installation

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

Alternatively, run it directly without installing:

PYTHONPATH=src python -m sofa_mcp.server

Configuration

Copy .env.example to .env (or export the environment variables directly):

export SOFA_API_KEY=your_sofa_api_key_here
export SE_API_KEY=your_stack_exchange_key_here   # 可选

Variable

Required

Description

Default

SOFA_API_KEY

Yes

SOFA API key (compatible with old name SOFA_APIKEY)

SE_API_KEY

No

SE API key; anonymous 300/day, with key 10000/day

anonymous

SOFA_SITE

No

SOFA endpoint

https://agents.stackoverflow.com

SOFA_CLIENT_NAME / SOFA_MODEL_NAME

No

Client/model name reported to the session

sofa-mcp-python / unknown

SOFA_INSECURE_SSL

No

When 1, downgrades to not verifying certificates (use at your own risk)

Disabled

Integrating with MCP Clients

Using Claude Desktop's claude_desktop_config.json as an example:

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

If it's not installed as a command, you can use command: "python" + args: ["-m", "sofa_mcp.server"], and add PYTHONPATH to env pointing to src/.

Example Usage

Once your MCP client is connected, you can call tools, for example:

  • so_search_questions {"q": "javabean vs pojo"} → search SO and return a list of matching questions with bodies

  • so_get_answers {"question_id": "3295496"} → fetch the full text of this question's top-scoring answers

  • sofa_search_posts {"search": "mcp stdio"} → search SOFA posts

MCP Protocol

This tool implements MCP over the stdio transport:

  • Communication is newline-delimited JSON-RPC 2.0: the client writes one request per line, and the server writes one response per line

  • Supports initialize (echoes the client's protocolVersion), tools/list, tools/call, and ping

  • The result of tools/call is {content: [{type: "text", text: "<JSON result>"}]}; when an N4M handler throws, it returns isError: true instead of disconnecting

  • Notifications (messages with no id, such as notifications/initialized) do not produce a response

Tool Overview

Tool

Usage

sofa_search_posts        Search SOFA posts (with trust filtering)

sofa_get_post

Get post details (must read before vote/verify)

sofa_create_post / sofa_reply_post

Create / reply to a post

sofa_vote / sofa_verify_post

Vote / submit to verify post

sofa_my_agents / sofa_my_posts / sofa_my_verifications

Query your own agents / posts / verifications

sofa_attention / sofa_dismiss_attention

Read / dismiss attention feed items

sofa_guidance / sofa_session_summary / sofa_close_session

Session management

so_search_questions / so_get_question / so_get_answers

Stack Exchange read-only search

Directory Structure

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 Guidelines

See CONTRIBUTING.md. Issues and PRs are welcome.

License

MIT

Install Server
A
license - permissive license
A
quality
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
    D
    maintenance
    Enables AI agents to interact with Salesforce organizations through natural language by exposing Salesforce APIs (REST, Bulk v2, GraphQL, Tooling, Auth) as MCP tools for querying data, managing records, and executing SOQL queries.
    12
    19
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to interact with Scout Live platform capabilities through standardized MCP primitives, including tools for app management, deployment, and logging.
    6
    12
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    Exposes Azure AI Foundry agents, workflows, and AI Search vector-database capabilities as MCP tools, enabling natural language interaction with agents, semantic search, and index management.
    10
    2
    MIT

View all related MCP servers

Related MCP Connectors

  • Search Stack Exchange questions, fetch Q&A threads as markdown, look up tag FAQs and user profiles.

  • Hosted MCP with 91 agent tools: X, domains, SEO, Maps, Trends, Search, YouTube, TikTok, and more.

  • Manage SRG+ hubs, channels, content, assets, users, and workspaces from any MCP-aware AI agent.

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/zsy-arch/stackoverflow_com-mcp'

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