Spaces:
Runtime error
Runtime error
Commit ·
d71b95a
1
Parent(s): cd3cd19
updated tests
Browse filesFiles changed (5)
- LINKEDIN_POST.mdAdded+116
- README.md+19-12
- app.py+110-6
- mcp_example/server.pyAdded+31
- samples/sample_bigquery.sqlAdded+5
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116# LinkedIn Post - Lineage Graph Accelerator #MCP-1st-Birthday
## Post Text (Ready to Share)
Excited to share **Lineage Graph Accelerator** 🔥 — an AI-powered agent I've built as a submission for the **#MCP-1st-Birthday celebration**!
🎯 **What it does:**Extract and visualize complex data lineage from multiple sources (BigQuery, dbt, Airflow, APIs) in seconds. Transform metadata into clear, interactive Mermaid diagrams that help teams understand data relationships and dependencies.
🏗️ **Architecture Highlights:**- Modular agent-based design with sub-agents for parsing, visualization, and integrations- Built with **Langsmith's Agent Builder** for flexible orchestration- **Gradio** UI for interactive exploration- Client-side **Mermaid** rendering for instant visual feedback
✨ **Key Features:**- Multi-source metadata ingestion (Text, BigQuery, URLs/APIs)- AI-assisted relationship extraction- Dynamic graph visualization (Mermaid + DOT support)- Lightweight, extensible, and fully tested
📦 **Try it now:** Live demo available on Hugging Face Spaces (link in comments)
This project showcases how modular AI agents can tackle real-world data challenges. Special thanks to **@Langsmith**, **@Gradio**, and the **@HuggingFace** teams for the amazing tools!
🔗 **Learn more:** Check out the repo for quickstart guide, unit tests, and integration examples.
---
## Hashtags & Tags
### Primary Tags (LinkedIn):#MCP-1st-Birthday#MCP#ModelContextProtocol
### Technology Tags:#Gradio#HuggingFace#LangSmith#DataLineage#DataEngineering#AI#Agents#Python
### Topic Tags:#DataViz#MetadataManagement#BigQuery#dbt#Airflow#DataGovernance
### Community Tags:#OpenSource#Developers#TechInnovation
---
## Social Media Context
**For LinkedIn Comment (link to live demo):**"Live demo: [Hugging Face Spaces URL]"
**For GitHub/Repo Share:**"Open source project ready for contributions! Check the README for setup, testing, and integration guides. 🚀"
**For Twitter/X (condensed version):**"Just released Lineage Graph Accelerator 🔥—an AI-powered agent for visualizing data lineage across BigQuery, dbt, Airflow & more. Built with Langsmith + Gradio. Submitted for #MCP-1st-Birthday 🎉 #DataEngineering #OpenSource"
---
## Suggested Mentions (Tag in comments or separate posts):
1. @LangSmith / @LangChain (for Agent Builder inspiration)2. @Gradio (for the UI framework)3. @Hugging Face (for Spaces hosting)4. @MCP-1st-Birthday (Hugging Face organization)5. @dbt-labs (if integrating dbt features)6. @BigQuery team (for metadata integration)
---
## Optional Follow-up Post (48 hours later):
"Week 1 update on Lineage Graph Accelerator 🔥:- [X] Deployed to Hugging Face Spaces- [X] Full test coverage + CI/CD ready- [ ] Community feedback & PRs- [ ] dbt integration alpha- [ ] Snowflake connector
Open source projects thrive on collaboration—if you're interested in data lineage, metadata management, or AI agents, I'd love your input! 👇"
---
## Tips for Sharing:
✅ **Do:**- Add a screenshot of the Mermaid diagram in action- Link to the GitHub repo and live demo- Tag the relevant teams/organizations- Use 2-3 relevant hashtags per line (LinkedIn limit)- Post during peak hours (8-10 AM, 12-1 PM, 5-6 PM on weekdays)
⚠️ **Avoid:**- Overly technical jargon without explanation- Too many hashtags (stick to 15-20 max)- Posting at midnight (low engagement)- Neglecting to engage with comments in first 2 hours
---
**Questions?** Feel free to customize this post with your personal voice and experiences!106 unmodified lines107108109110111112113114115116117118119120121122123106 unmodified lines## LicenseMIT---title: Lineage Graph Acceleratoremoji: 🔥colorFrom: graycolorTo: graysdk: gradiosdk_version: 5.49.1app_file: app.pypinned: falselicense: mitshort_description: An agent that extracts data lineage, pipeline dependencies---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference106 unmodified lines107108109110111112113114115116117118119120121122123124125126127128129130106 unmodified lines## LicenseMIT## Example MCP server (local testing)If you want to test the MCP flow locally, start the example MCP server included in `mcp_example/`.Run the example server (from project root):```bash# Activate venv first if you use oneuvicorn mcp_example.server:app --reload --port 9000```Then set the `MCP Server URL` in the UI to:```http://127.0.0.1:9000/mcp```When `MCP Server URL` is configured in the app the extraction buttons will prefer the MCP server and send metadata to it; if the MCP server returns a visualization the app will render it. If `MCP Server URL` is empty, the app falls back to local extractor stubs.Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
5 unmodified lines6789101117 unmodified lines293031323334121 unmodified lines15615715815916016117 unmodified lines1791801811821831841851861871888 unmodified lines19719819920020120217 unmodified lines2202212222232242252262272282293 unmodified lines23323423523623723812 unmodified lines2512522532542552562572582592605 unmodified linesimport gradio as grimport jsonimport osfrom typing import Optional, Tuple17 unmodified lines)return f"<div class=\"mermaid\">{safe_viz}</div>{init_script}"# Note: This is a template. You'll need to integrate with your actual agent backend.# This could be through an API, Claude SDK, or other agent framework.121 unmodified linesplaceholder="Paste your metadata here (JSON, YAML, SQL, etc.)",lines=15)source_type_text = gr.Dropdown(choices=["dbt Manifest", "Airflow DAG", "SQL DDL", "Custom JSON", "Other"],label="Source Type",17 unmodified lines)extract_btn_text.click(fn=extract_lineage_from_text,inputs=[metadata_input, source_type_text, viz_format_text],outputs=[output_viz_text, output_summary_text])# Tab 2: BigQuerywith gr.Tab("BigQuery"):8 unmodified linesplaceholder="SELECT * FROM `project.dataset.INFORMATION_SCHEMA.TABLES`",lines=8)bq_api_key = gr.Textbox(label="API Key / Credentials",placeholder="Enter your credentials",17 unmodified lines)extract_btn_bq.click(fn=extract_lineage_from_bigquery,inputs=[bq_project, bq_query, bq_api_key, viz_format_bq],outputs=[output_viz_bq, output_summary_bq])# Tab 3: URL/APIwith gr.Tab("URL/API"):3 unmodified lineslabel="URL",placeholder="https://api.example.com/metadata")viz_format_url = gr.Dropdown(choices=["Mermaid", "DOT/Graphviz", "Text", "All"],label="Visualization Format",12 unmodified lines)extract_btn_url.click(fn=extract_lineage_from_url,inputs=[url_input, viz_format_url],outputs=[output_viz_url, output_summary_url])gr.Markdown("""---5 unmodified lines678910111217 unmodified lines30313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108121 unmodified lines23023123223323423523617 unmodified lines2542552562572582592602612622632642652662672682692702712728 unmodified lines28128228328428528628717 unmodified lines3053063073083093103113123133143153163173183193203213223233 unmodified lines32732832933033133233312 unmodified lines3463473483493503513523533543553563573583593603613623633645 unmodified linesimport gradio as grimport jsonimport osimport requestsfrom typing import Optional, Tuple17 unmodified lines)return f"<div class=\"mermaid\">{safe_viz}</div>{init_script}"def send_to_mcp(server_url: str, api_key: str, metadata_text: str, source_type: str, viz_format: str) -> Tuple[str, str]:"""Send the metadata to an external MCP server (e.g., hosted on Hugging Face) and return visualization + summary.This is optional — if no MCP server is configured the local stub extractors will be used."""if not server_url:return "", "No MCP server URL configured."try:payload = {"metadata": metadata_text,"source_type": source_type,"viz_format": viz_format,}headers = {}if api_key:headers["Authorization"] = f"Bearer {api_key}"resp = requests.post(server_url, json=payload, headers=headers, timeout=15)if resp.status_code >= 200 and resp.status_code < 300:data = resp.json()viz = data.get("visualization") or data.get("viz") or data.get("mermaid", "")summary = data.get("summary", "Processed by MCP server.")if viz:return render_mermaid(viz), summaryelse:return "", summaryelse:return "", f"MCP server returned status {resp.status_code}: {resp.text[:200]}"except Exception as e:return "", f"Error contacting MCP server: {e}"def test_mcp_connection(server_url: str, api_key: str) -> str:"""Simple health-check to MCP server (sends a small ping)."""if not server_url:return "No MCP server URL configured."try:headers = {}if api_key:headers["Authorization"] = f"Bearer {api_key}"resp = requests.get(server_url, headers=headers, timeout=10)return f"MCP server responded: {resp.status_code} {resp.reason}"except Exception as e:return f"Error contacting MCP server: {e}"# Wrapper handlers: prefer MCP server if configured, otherwise fall back to local extractors.def handle_extract_text(metadata_text: str, source_type: str, visualization_format: str, mcp_server: str, mcp_api_key: str) -> Tuple[str, str]:if mcp_server:viz, summary = send_to_mcp(mcp_server, mcp_api_key, metadata_text, source_type, visualization_format)# If MCP returned something, use it. Otherwise fall back to local.if viz or (summary and not summary.startswith("Error")):return viz, summaryreturn extract_lineage_from_text(metadata_text, source_type, visualization_format)def handle_extract_bigquery(project_id: str, query: str, api_key: str, visualization_format: str, mcp_server: str, mcp_api_key: str) -> Tuple[str, str]:if mcp_server:# Send query as metadata to MCP; source_type indicates BigQueryviz, summary = send_to_mcp(mcp_server, mcp_api_key, query, "BigQuery", visualization_format)if viz or (summary and not summary.startswith("Error")):return viz, summaryreturn extract_lineage_from_bigquery(project_id, query, api_key, visualization_format)def handle_extract_url(url: str, visualization_format: str, mcp_server: str, mcp_api_key: str) -> Tuple[str, str]:if mcp_server:# Send the URL (MCP can fetch it or interpret it) as metadataviz, summary = send_to_mcp(mcp_server, mcp_api_key, url, "URL", visualization_format)if viz or (summary and not summary.startswith("Error")):return viz, summaryreturn extract_lineage_from_url(url, visualization_format)# Note: This is a template. You'll need to integrate with your actual agent backend.# This could be through an API, Claude SDK, or other agent framework.121 unmodified linesplaceholder="Paste your metadata here (JSON, YAML, SQL, etc.)",lines=15)load_sample_text_btn = gr.Button("Load sample metadata")source_type_text = gr.Dropdown(choices=["dbt Manifest", "Airflow DAG", "SQL DDL", "Custom JSON", "Other"],label="Source Type",17 unmodified lines)extract_btn_text.click(fn=handle_extract_text,inputs=[metadata_input, source_type_text, viz_format_text, mcp_server, mcp_api_key],outputs=[output_viz_text, output_summary_text])def load_sample_text():p = os.path.join(os.path.dirname(__file__), "samples", "sample_metadata.json")try:with open(p, "r") as f:return f.read()except Exception:return "{\"error\": \"Could not load sample metadata\"}"load_sample_text_btn.click(fn=load_sample_text, inputs=[], outputs=[metadata_input])# Tab 2: BigQuerywith gr.Tab("BigQuery"):8 unmodified linesplaceholder="SELECT * FROM `project.dataset.INFORMATION_SCHEMA.TABLES`",lines=8)load_sample_bq_btn = gr.Button("Load sample BigQuery query")bq_api_key = gr.Textbox(label="API Key / Credentials",placeholder="Enter your credentials",17 unmodified lines)extract_btn_bq.click(fn=handle_extract_bigquery,inputs=[bq_project, bq_query, bq_api_key, viz_format_bq, mcp_server, mcp_api_key],outputs=[output_viz_bq, output_summary_bq])def load_sample_bq():p = os.path.join(os.path.dirname(__file__), "samples", "sample_bigquery.sql")try:with open(p, "r") as f:return f.read()except Exception:return "-- Could not load sample BigQuery SQL"load_sample_bq_btn.click(fn=load_sample_bq, inputs=[], outputs=[bq_query])# Tab 3: URL/APIwith gr.Tab("URL/API"):3 unmodified lineslabel="URL",placeholder="https://api.example.com/metadata")load_sample_url_btn = gr.Button("Load sample API metadata")viz_format_url = gr.Dropdown(choices=["Mermaid", "DOT/Graphviz", "Text", "All"],label="Visualization Format",12 unmodified lines)extract_btn_url.click(fn=handle_extract_url,inputs=[url_input, viz_format_url, mcp_server, mcp_api_key],outputs=[output_viz_url, output_summary_url])def load_sample_url():p = os.path.join(os.path.dirname(__file__), "samples", "sample_api_metadata.json")try:with open(p, "r") as f:return f.read()except Exception:return "{\"error\": \"Could not load sample API metadata\"}"load_sample_url_btn.click(fn=load_sample_url, inputs=[], outputs=[url_input])gr.Markdown("""---
12345678910111213141516171819202122232425262728293031from fastapi import FastAPIfrom pydantic import BaseModel
app = FastAPI(title="Example MCP Server")
class MCPRequest(BaseModel): metadata: str source_type: str viz_format: str
@app.get("/")def root(): return {"status": "ok", "message": "Example MCP server running"}
@app.post("/mcp")def mcp_endpoint(req: MCPRequest): """Simple example endpoint that returns a sample mermaid diagram and summary.
This is intentionally minimal — a real MCP server would run the agent pipeline and return an appropriate visualization and structured metadata. """ # Create a small mermaid graph that incorporates the source_type for demonstration mermaid = f"graph TD\n A[{req.source_type}] --> B[Processed by Example MCP]" summary = f"Example MCP processed source_type={req.source_type}, viz_format={req.viz_format}" return {"mermaid": mermaid, "visualization": mermaid, "summary": summary}
# Run with: uvicorn mcp_example.server:app --reload --port 900012345-- Sample BigQuery metadata query (for demonstration)-- This is not run automatically; it's a sample string users can paste into the UI.SELECT table_name, column_name, data_typeFROM `project.dataset.INFORMATION_SCHEMA.COLUMNS`WHERE table_name IN ('raw_customers', 'clean_customers', 'orders');LINKEDIN_POST.mdAdded+116
README.md+19-12
app.py+110-6
mcp_example/server.pyAdded+31
samples/sample_bigquery.sqlAdded+5