Skip to content

Phase 20: MCP Server — FLUX als Tool für LLMs - #33

Merged
MarcoFPO merged 4 commits into
mainfrom
feature/phase-20-mcp
Mar 14, 2026
Merged

Phase 20: MCP Server — FLUX als Tool für LLMs#33
MarcoFPO merged 4 commits into
mainfrom
feature/phase-20-mcp

Conversation

@MarcoFPO

Copy link
Copy Markdown
Owner

Summary

  • MCP-Server (flux-mcp binary) via JSON-RPC 2.0 über stdio
  • 6 Tools: flux_check, flux_compile, flux_build, flux_ir, flux_evolve, flux_prove
  • Shared pipeline.rs Modul (aus main.rs extrahiert) für CLI und MCP
  • 11 MCP-Integrationstests

Architektur

  • src/bin/flux-mcp.rs — Standalone MCP-Server ohne externe MCP-Crates
  • src/pipeline.rs — Gemeinsame Pipeline-Logik (run_check, run_check_with_bmc)
  • src/main.rs — Vereinfacht, nutzt pipeline.rs statt eigener Implementierung

Test plan

  • cargo build --bin flux-mcp kompiliert
  • cargo clippy --all-targets -- -D warnings fehlerfrei
  • 11 MCP-Tests bestehen (initialize, tools/list, 6 Tool-Calls, Fehlerbehandlung)
  • Alle 271 bestehenden Tests bestehen weiterhin
  • CI/CD Pipeline grün

Closes #32

🤖 Generated with Claude Code

Marco Doehler and others added 3 commits March 14, 2026 19:03
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Implementiert einen MCP-Server (flux-mcp binary) der die FLUX-Pipeline
über stdio als JSON-RPC 2.0 Tools exponiert. Extrahiert pipeline.rs als
shared module für CLI und MCP.

6 Tools: flux_check, flux_compile, flux_build, flux_ir, flux_evolve, flux_prove
11 MCP-Tests, alle bestehenden 271 Tests bestehen weiterhin.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Extends the MCP test suite with 3 additional integration tests:
- mcp_invalid_json: verifies -32700 parse error response
- mcp_notification_no_response: verifies notifications are silent
- mcp_flux_evolve_valid: validates evolution tool with seed

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

Dieser Pull Request führt einen Model Context Protocol (MCP)-Server für FLUX FTL ein, der die Interaktion mit der Compiler-Pipeline über JSON-RPC 2.0 ermöglicht. Ziel ist es, die Integration der FLUX FTL-Tools in größere Systeme, insbesondere in Large Language Models (LLMs), zu vereinfachen. Durch die Bereitstellung einer standardisierten Schnittstelle können externe Anwendungen die Kernfunktionen des Compilers programmatisch nutzen, was die Automatisierung und Entwicklung von AI-gesteuerten Workflows erheblich verbessert. Die Auslagerung der Pipeline-Logik in ein separates Modul fördert zudem die Code-Wiederverwendbarkeit und Wartbarkeit.

Highlights

  • Neuer MCP-Server: Ein eigenständiger Model Context Protocol (MCP)-Server wurde hinzugefügt, der über JSON-RPC 2.0 via Standard-I/O kommuniziert.
  • Sechs neue Tools für LLMs: Der MCP-Server stellt sechs Tools bereit (flux_check, flux_compile, flux_build, flux_ir, flux_evolve, flux_prove), die die FLUX FTL-Compiler-Pipeline für externe Systeme zugänglich machen.
  • Extrahiertes pipeline.rs-Modul: Die gemeinsame Logik der Compiler-Pipeline wurde aus src/main.rs in ein neues, wiederverwendbares Modul src/pipeline.rs ausgelagert.
  • Umfassende MCP-Integrationstests: Elf neue Integrationstests wurden hinzugefügt, um die Funktionalität und Robustheit des MCP-Servers zu gewährleisten.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • flux-ftl/Cargo.toml
    • Neue Binärziele für flux-ftl und flux-mcp wurden hinzugefügt.
  • flux-ftl/src/bin/flux-mcp.rs
    • Eine neue Binärdatei für den Model Context Protocol (MCP)-Server wurde erstellt.
  • flux-ftl/src/lib.rs
    • Das neue pipeline-Modul wurde zur Bibliothek hinzugefügt.
  • flux-ftl/src/main.rs
    • Die Haupt-CLI-Anwendung wurde refaktorisiert, um das gemeinsam genutzte pipeline-Modul zu verwenden.
  • flux-ftl/src/pipeline.rs
    • Ein neues Modul wurde eingeführt, um die gemeinsame Logik der FTL-Kompilierungs-Pipeline zu kapseln.
  • flux-ftl/tests/mcp_tests.rs
    • Integrationstests für den neuen MCP-Server wurden hinzugefügt.
  • ftl-examples.md
    • Eine neue Dokumentationsdatei mit FTL-Codebeispielen wurde hinzugefügt.
  • ftl-spec.md
    • Eine neue Dokumentationsdatei, die die FTL-Sprachspezifikation detailliert, wurde hinzugefügt.
  • mcp-integration.md
    • Eine neue Dokumentationsdatei, die die MCP-Server-Integration und ihre Tools beschreibt, wurde hinzugefügt.
Activity
  • Keine menschliche Aktivität in diesem Pull Request bisher.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

Dieser Pull Request führt einen MCP-Server für FLUX ein, der die Compiler-Pipeline als Tools für LLMs über JSON-RPC bereitstellt. Die Implementierung ist gut strukturiert, insbesondere durch die Extraktion der gemeinsamen Logik in ein pipeline.rs-Modul, was die Wiederverwendung von Code zwischen der CLI und dem neuen MCP-Server ermöglicht. Die hinzugefügten Integrationstests decken die Kernfunktionalität und Fehlerfälle gut ab.

Ich habe einige Verbesserungsvorschläge zur Fehlerbehandlung im MCP-Server gemacht, um die Robustheit und die API-Konsistenz zu erhöhen. Insbesondere schlage ich vor, I/O-Fehler beim Senden von Antworten zu behandeln und die Serialisierungsfehler konsistenter zu melden, um die Client-Implementierung zu vereinfachen.

Comment on lines +78 to +79
let _ = writeln!(out, "{}", json);
let _ = out.flush();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Die Ergebnisse von writeln! und flush werden hier ignoriert. Wenn das Schreiben nach stdout fehlschlägt, wird der Client keine Antwort erhalten und wahrscheinlich hängen bleiben. Da die Kommunikation über stdio für diesen Server kritisch ist, sollten diese Fehler behandelt werden. Ein panic wäre in diesem Fall angemessen, da der Server in einem inkonsistenten Zustand wäre, wenn er nicht mit dem Client kommunizieren kann.

Suggested change
let _ = writeln!(out, "{}", json);
let _ = out.flush();
writeln!(out, "{}").expect("failed to write to stdout");
out.flush().expect("failed to flush stdout");

Comment on lines +331 to +333
let json = serde_json::to_string(&metadata)
.unwrap_or_else(|e| format!("{{\"error\": \"{}\"}}", e));
send_tool_result(stdout, id, &json);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Wenn die Serialisierung von metadata fehlschlägt, wird eine JSON-Fehlermeldung als erfolgreiches tool_result gesendet. Dies zwingt den Client, den Textinhalt zu parsen, um nach Fehlern zu suchen. Es ist besser, im Fehlerfall send_tool_error zu verwenden, um einen korrekten tool_result mit "isError": true zu senden. Dies verbessert die API-Konsistenz und vereinfacht die Fehlerbehandlung auf Client-Seite.

            match serde_json::to_string(&metadata) {
                Ok(json) => send_tool_result(stdout, id, &json),
                Err(e) => send_tool_error(stdout, id, &format!("Serialization error: {}", e)),
            }

Comment on lines +612 to +615
let json = serde_json::to_string(&proof_results)
.unwrap_or_else(|e| format!("{{\"error\": \"{}\"}}", e));

send_tool_result(stdout, id, &json);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Wenn die Serialisierung von proof_results fehlschlägt, wird eine JSON-Fehlermeldung als erfolgreiches tool_result gesendet. Dies ist inkonsistent mit der Fehlerbehandlung an anderen Stellen und erschwert die Fehlerbehandlung für den Client. Verwenden Sie stattdessen send_tool_error, um einen korrekten tool_result mit "isError": true zu senden.

    match serde_json::to_string(&proof_results) {
        Ok(json) => send_tool_result(stdout, id, &json),
        Err(e) => send_tool_error(stdout, id, &format!("Serialization error: {}", e)),
    }

@MarcoFPO
MarcoFPO merged commit b44c092 into main Mar 14, 2026
1 check passed
@MarcoFPO
MarcoFPO deleted the feature/phase-20-mcp branch March 14, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 20: MCP Server — FLUX als Tool für LLMs

1 participant