发现优秀的 MCP 服务器

通过 MCP 服务器扩展您的代理能力,拥有 86,267 个能力。

开发者工具3,065
Telegram MCP Server

Telegram MCP Server

MCP服务器向Telegram发送通知

McpDocs

McpDocs

Okay, this is a complex task involving several moving parts. Here's a breakdown of how you can provide Elixir project documentation (including dependencies) to an LLM via an SSE (Server-Sent Events) MCP (Message Channel Protocol) server. I'll outline the steps, tools, and considerations. **Conceptual Overview** 1. **Documentation Extraction:** You need to extract the documentation from your Elixir project and its dependencies. This involves parsing the Elixir code and extracting the `@doc` attributes, type specifications, and module/function signatures. 2. **Data Formatting:** The extracted documentation needs to be formatted into a structured format suitable for an LLM. JSON is a common choice. Consider including metadata like module name, function name, arity, and the actual documentation string. 3. **SSE Server:** You'll need an Elixir-based SSE server that can stream the formatted documentation to the LLM. This server will listen for a connection from the LLM and then push the documentation data as SSE events. 4. **MCP Integration (if needed):** If you need to use MCP, you'll need to integrate an MCP library into your Elixir SSE server. MCP provides a standardized way for clients (like your LLM) to discover and connect to services. 5. **LLM Integration:** The LLM needs to be configured to connect to the SSE server (and potentially use MCP to discover it) and consume the SSE events. The LLM will then process the documentation data to learn about your project. **Detailed Steps and Code Examples** **1. Documentation Extraction** * **Using `ExDoc` (Recommended):** `ExDoc` is the standard documentation generator for Elixir projects. It can generate HTML documentation, but more importantly, it provides an API for programmatically accessing the documentation data. * **Add `ExDoc` to your `mix.exs`:** ```elixir def deps do [ {:ex_doc, "~> 0.31", only: :dev, runtime: false} ] end ``` * **Use `ExDoc.Markdown.parse/1` and `ExDoc.Type.to_string/1`:** You can use `ExDoc`'s internal functions to parse the documentation strings and type specifications. This gives you a structured representation of the documentation. * **Example (Conceptual):** ```elixir defmodule DocExtractor do require Logger def extract_docs(project_path) do # This is a simplified example. You'll need to adapt it to your project structure. Mix.Task.run("compile", ["--warnings-as-errors"]) # Ensure code is compiled Mix.Task.run("docs", []) # Generate docs (necessary for ExDoc to work) Enum.map(Mix.Project.config()[:modules], fn module -> try do module |> Module.concat(".ex") |> Code.require_file() module |> Module.concat(".ex") |> File.read!() |> extract_module_docs(module) rescue e -> Logger.error("Error extracting docs for #{module}: #{inspect(e)}") [] end end) |> List.flatten() end defp extract_module_docs(file_content, module) do # This is a very basic example. You'll need to use a proper Elixir parser # (like `Code.string_to_quoted/1` and then traverse the AST) to reliably # extract the @doc attributes and function definitions. This is a complex task. # The following is a placeholder. # Example using Regex (fragile, but illustrative): Regex.scan(~r/@doc """(.*?)"""\s+def\s+(.*?)\(/ms, file_content) |> Enum.map(fn [doc, function_name] -> %{ module: module, function: function_name, doc: String.trim(doc) } end) end end # Example usage: # docs = DocExtractor.extract_docs(".") # "." is the current project directory # IO.inspect(docs) ``` * **Important Considerations for `ExDoc`:** * `ExDoc` relies on the code being compiled and the documentation being generated. Make sure you run `mix compile` and `mix docs` before attempting to extract the documentation programmatically. * Directly accessing `ExDoc`'s internal data structures can be fragile, as the internal implementation might change between versions. Consider using the HTML output and parsing it if a more stable API is needed. * Handling dependencies: You'll need to iterate through your project's dependencies and extract documentation from them as well. This might involve finding the dependency's source code and running `ExDoc` on it. * **Alternative: AST Parsing (Advanced):** You can use Elixir's `Code.string_to_quoted/1` function to parse the Elixir code into an Abstract Syntax Tree (AST). You can then traverse the AST to find `@doc` attributes, function definitions, and type specifications. This approach is more robust but also more complex. Libraries like `Macro` can help with AST manipulation. **2. Data Formatting (JSON)** * **Example JSON Structure:** ```json [ { "module": "MyModule", "function": "my_function", "arity": 1, "doc": "This function does something.", "spec": "my_function(integer) :: string" }, { "module": "MyModule", "function": "another_function", "arity": 2, "doc": "This function does something else.", "spec": "another_function(string, boolean) :: atom" } ] ``` * **Elixir Code to Generate JSON:** ```elixir defmodule JsonFormatter do def format_docs(docs) do docs |> Enum.map(fn doc -> %{ module: doc.module, function: doc.function, arity: doc.arity || 0, # Add arity if available doc: doc.doc, spec: doc.spec || "" # Add spec if available } end) |> Jason.encode! # Use Jason or Poison for JSON encoding end end ``` **3. SSE Server** * **Using `Plug` and `Cowboy`:** `Plug` is a specification for building web applications in Elixir, and `Cowboy` is a popular web server that implements the `Plug` specification. * **Add dependencies to `mix.exs`:** ```elixir def deps do [ {:plug, "~> 1.14"}, {:cowboy, "~> 2.10"}, {:jason, "~> 1.4"} # For JSON encoding ] end ``` * **Create a Plug module:** ```elixir defmodule DocServer do use Plug.Router require Logger def init(_opts) do :ok end def call(conn, _opts) do dispatch(conn) end plug Plug.Logger plug :match plug :dispatch get "/docs" do conn = conn |> Plug.Conn.put_resp_content_type("text/event-stream") |> Plug.Conn.put_resp_header("cache-control", "no-cache") |> Plug.Conn.send_resp(200, stream_docs()) end match _ do send_resp(conn, 404, "Not Found") end defp stream_docs() do # Replace this with your actual documentation extraction and formatting logic docs = DocExtractor.extract_docs(".") # Extract docs from the project json_string = JsonFormatter.format_docs(docs) # Format as JSON # Split the JSON string into smaller chunks for streaming chunks = String.split(json_string, "") |> Enum.chunk_every(500) Enum.reduce(chunks, "", fn chunk, acc -> event_data = "data: " <> Enum.join(chunk, "") <> "\n\n" acc <> event_data end) end end ``` * **Start the server in your `application.ex`:** ```elixir def start(_type, _args) do children = [ {Plug.Cowboy, scheme: :http, plug: DocServer, options: [port: 4000]} ] Supervisor.start_link(children, strategy: :one_for_one) end ``` * **Explanation:** * The `/docs` endpoint serves the SSE stream. * `Plug.Conn.put_resp_content_type("text/event-stream")` sets the correct content type for SSE. * `Plug.Conn.put_resp_header("cache-control", "no-cache")` disables caching. * `stream_docs()` is where you'll extract, format, and stream the documentation. The example shows how to split the JSON string into chunks to avoid sending very large events. * Each SSE event is formatted as `data: <your_data>\n\n`. **4. MCP Integration (Optional)** * **Choose an MCP Library:** There are several MCP libraries available for Elixir. Research and choose one that suits your needs. Some options might include libraries that wrap existing MCP implementations. * **Integrate the Library:** Follow the library's documentation to integrate it into your SSE server. This will typically involve: * Adding the library as a dependency in `mix.exs`. * Configuring the MCP server address and other settings. * Registering your SSE service with the MCP server. This allows the LLM to discover your service. * **Example (Conceptual - using a hypothetical MCP library):** ```elixir defmodule DocServer do use Plug.Router require Logger @mcp_server "mcp.example.com:8080" # Replace with your MCP server address def init(_opts) do # Register the service with the MCP server :ok = MCP.register_service(@mcp_server, "elixir-doc-server", "/docs") :ok end # ... (rest of the DocServer code) ... end ``` **5. LLM Integration** * **LLM Configuration:** Configure your LLM to connect to the SSE server. This will typically involve: * Providing the URL of the SSE endpoint (e.g., `http://localhost:4000/docs`). * If using MCP, configuring the LLM to use the MCP server to discover the service. * **SSE Event Handling:** The LLM needs to be able to parse the SSE events and extract the JSON data. Most LLM frameworks have libraries or built-in support for handling SSE streams. * **Data Processing:** The LLM will then process the JSON data to learn about your Elixir project's documentation. This might involve: * Indexing the documentation for efficient retrieval. * Using the documentation to answer questions about the project. * Using the documentation to generate code or documentation. **Important Considerations and Best Practices** * **Error Handling:** Implement robust error handling throughout the process. Log errors to help with debugging. * **Security:** If you're exposing the SSE server to the internet, consider security measures such as authentication and authorization. * **Scalability:** If you need to handle a large number of LLM connections, consider using a more scalable web server than `Cowboy` (e.g., `Phoenix` with `Cowboy2`). * **Chunking:** Sending large SSE events can cause performance problems. Chunk the data into smaller events. * **Heartbeats:** Implement a heartbeat mechanism to ensure that the connection between the LLM and the SSE server is still alive. The server can send a periodic "ping" event, and the LLM can respond with a "pong" event. * **Dependencies:** Carefully manage your project's dependencies. Use a dependency management tool like `mix` to ensure that you're using compatible versions of all libraries. * **Testing:** Write unit tests and integration tests to ensure that your code is working correctly. * **Rate Limiting:** Implement rate limiting on the SSE server to prevent the LLM from overwhelming the server with requests. * **Documentation Updates:** Consider how you'll handle documentation updates. You might need to implement a mechanism to notify the LLM when the documentation has changed. **Example LLM Integration (Conceptual - Python)** ```python import sseclient import requests import json url = 'http://localhost:4000/docs' # Replace with your SSE server URL try: response = requests.get(url, stream=True) response.raise_for_status() # Raise HTTPError for bad responses (4xx or 5xx) client = sseclient.SSEClient(response) for event in client.events(): try: data = json.loads(event.data) print(f"Received data: {data}") # Process the documentation data here (e.g., index it, use it for QA) except json.JSONDecodeError as e: print(f"Error decoding JSON: {e}, data: {event.data}") except Exception as e: print(f"Error processing event: {e}") except requests.exceptions.RequestException as e: print(f"Request error: {e}") except Exception as e: print(f"General error: {e}") ``` **Summary** This is a complex project that requires a good understanding of Elixir, web servers, SSE, and LLMs. Start with the documentation extraction and SSE server, and then add MCP integration if needed. Remember to test your code thoroughly and handle errors gracefully. Good luck!

create-mcp-server

create-mcp-server

构建具有集成 Web 功能的强大模型上下文协议 (MCP) 服务器的综合架构

Servidor MCP para CRM con IA

Servidor MCP para CRM con IA

MCP Router

MCP Router

MCP Router 让你能够轻松管理你的 MCP (模型上下文协议) 服务器。

🐋 Docker MCP server

🐋 Docker MCP server

镜子 (jìng zi)

MCP MIDI Server

MCP MIDI Server

一个 MCP 服务器,用于将 MIDI 音序发送到任何支持 MIDI 输入的程序。

pumpfun-mcp

pumpfun-mcp

镜子 (jìng zi)

my-mcp-server

my-mcp-server

MCP Server Pool

MCP Server Pool

MCP 服务合集 (MCP fúwù héjí)

Moodle MCP Server

Moodle MCP Server

镜子 (jìng zi)

Mcp Servers Wiki Website

Mcp Servers Wiki Website

Cloudflare AI

Cloudflare AI

Googleworkspace Mcp

Googleworkspace Mcp

ChatGPT MCP Server

ChatGPT MCP Server

镜子 (jìng zi)

Apache Doris MCP Server

Apache Doris MCP Server

Apache Doris 和 VeloDB 的 MCP 服务器

MCP Server для Prom.ua

MCP Server для Prom.ua

MCP 服务器,用于与 Prom.ua API 交互

Creating an MCP Server in Go and Serving it with Docker

Creating an MCP Server in Go and Serving it with Docker

untapped-mcp

untapped-mcp

一个未被使用的 MCP 服务器,用于与 Claude 配合使用。

Payman AI Documentation MCP Server

Payman AI Documentation MCP Server

镜子 (jìng zi)

🤖 Agenite

🤖 Agenite

🤖 使用 TypeScript 构建强大的 AI 代理。Agenite 可以轻松创建、组合和控制 AI 代理,并提供对工具、流式传输和多代理架构的一流支持。在 OpenAI、Anthropic、AWS Bedrock 和 Ollama 等提供商之间无缝切换。

Firebase Docs MCP Server Setup

Firebase Docs MCP Server Setup

这是一个示例,展示了如何将 Firebase 文档用作 MCP 服务器(包括索引文档)。

Linear

Linear

MetaMCP MCP Server

MetaMCP MCP Server

镜子 (jìng zi)

mcp-server-fetch-typescript MCP Server

mcp-server-fetch-typescript MCP Server

镜子 (jìng zi)

mcptesting

mcptesting

通过 MCP 服务器创建的测试仓库

comment-stripper-mcp

comment-stripper-mcp

一个灵活的 MCP 服务器,可以批量处理代码文件,以删除多种编程语言中的注释。目前支持 JavaScript、TypeScript 和 Vue 文件,并使用基于正则表达式的模式匹配。可以处理单个文件、目录(包括子目录)和文本输入。专为代码的清洁维护和准备而构建。

Mcp Todo App

Mcp Todo App

一个结合了 MCP 服务器和客户端,并为简单的待办事项应用添加了一点 AI 功能的组合。

Remote MCP Server on Cloudflare

Remote MCP Server on Cloudflare

MCP Server Runner

MCP Server Runner

一个用于运行模型上下文协议(MCP)服务器的 WebSocket 服务器实现。此应用程序允许通过 WebSocket 连接访问 MCP 服务器,从而方便与 Web 应用程序和其他支持网络的客户端集成。