Spaces:
Sleeping
Sleeping
RDF Validation Deployment commited on
Commit Β·
0732ab2
1
Parent(s): db439cd
Convert to documentation-only interface - remove all interactive components, show MCP API docs only - 2025-10-04 15:55:52
Browse files
app.py
CHANGED
|
@@ -515,20 +515,131 @@ def get_property_usage(property_name: str, class_name: str = "") -> str:
|
|
| 515 |
|
| 516 |
return json.dumps(usage, indent=2)
|
| 517 |
|
| 518 |
-
# Create Gradio interface -
|
| 519 |
def create_interface():
|
| 520 |
|
| 521 |
with gr.Blocks(title="BIBFRAME MCP Server") as demo:
|
| 522 |
-
gr.Markdown("""
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 532 |
|
| 533 |
return demo
|
| 534 |
|
|
|
|
| 515 |
|
| 516 |
return json.dumps(usage, indent=2)
|
| 517 |
|
| 518 |
+
# Create Gradio interface - DOCUMENTATION ONLY (no interactive components)
|
| 519 |
def create_interface():
|
| 520 |
|
| 521 |
with gr.Blocks(title="BIBFRAME MCP Server") as demo:
|
| 522 |
+
gr.Markdown(f"""
|
| 523 |
+
# π BIBFRAME Ontology MCP Server
|
| 524 |
+
|
| 525 |
+
**Status:** β
Loaded {len(kb.properties)} properties and {len(kb.classes)} classes
|
| 526 |
+
|
| 527 |
+
This is a **Model Context Protocol (MCP)** server providing BIBFRAME ontology documentation tools.
|
| 528 |
+
The web interface is documentation only - use the MCP endpoint to query the ontology.
|
| 529 |
+
|
| 530 |
+
---
|
| 531 |
+
|
| 532 |
+
## π MCP Endpoint
|
| 533 |
+
|
| 534 |
+
**SSE Endpoint:** `https://jimfhahn-mcp4bibframe-docs.hf.space/gradio_api/mcp/sse`
|
| 535 |
+
|
| 536 |
+
---
|
| 537 |
+
|
| 538 |
+
## π οΈ Available MCP Tools
|
| 539 |
+
|
| 540 |
+
### 1. `get_property_info`
|
| 541 |
+
Get detailed information about a BIBFRAME property.
|
| 542 |
+
|
| 543 |
+
**Input:** `property_uri` (string) - e.g., "assigner", "bf:assigner", or "title"
|
| 544 |
+
|
| 545 |
+
**Returns:** JSON with property URI, label, definition, domain, range, examples, and usage notes
|
| 546 |
+
|
| 547 |
+
**Example:**
|
| 548 |
+
```json
|
| 549 |
+
{{
|
| 550 |
+
"property": "bf:assigner",
|
| 551 |
+
"label": "Assigner",
|
| 552 |
+
"definition": "Entity who assigned the identifier or other metadata value",
|
| 553 |
+
"domain": ["bf:AdminMetadata"],
|
| 554 |
+
"range": ["bf:Agent"],
|
| 555 |
+
"examples": ["<bf:assigner rdf:resource='http://id.loc.gov/rwo/agents/n123'/>"]
|
| 556 |
+
}}
|
| 557 |
+
```
|
| 558 |
+
|
| 559 |
+
---
|
| 560 |
+
|
| 561 |
+
### 2. `get_class_info`
|
| 562 |
+
Get detailed information about a BIBFRAME class.
|
| 563 |
+
|
| 564 |
+
**Input:** `class_name` (string) - e.g., "Work", "bf:Work", or "Instance"
|
| 565 |
+
|
| 566 |
+
**Returns:** JSON with class URI, label, definition, superclasses, and applicable properties
|
| 567 |
+
|
| 568 |
+
**Example:**
|
| 569 |
+
```json
|
| 570 |
+
{{
|
| 571 |
+
"class": "bf:Work",
|
| 572 |
+
"label": "Work",
|
| 573 |
+
"definition": "Most abstract level of description for a creative concept",
|
| 574 |
+
"applicable_properties": [
|
| 575 |
+
{{"property": "bf:title", "label": "Title"}},
|
| 576 |
+
{{"property": "bf:contribution", "label": "Contribution"}}
|
| 577 |
+
]
|
| 578 |
+
}}
|
| 579 |
+
```
|
| 580 |
+
|
| 581 |
+
---
|
| 582 |
+
|
| 583 |
+
### 3. `search_ontology`
|
| 584 |
+
Search for properties or classes matching a term.
|
| 585 |
+
|
| 586 |
+
**Inputs:**
|
| 587 |
+
- `search_term` (string) - e.g., "title", "agent", "date"
|
| 588 |
+
- `search_type` (string) - "all", "properties", or "classes"
|
| 589 |
+
|
| 590 |
+
**Returns:** JSON with matching properties and classes (max 20 each)
|
| 591 |
+
|
| 592 |
+
---
|
| 593 |
+
|
| 594 |
+
### 4. `get_property_usage`
|
| 595 |
+
Get usage information for a property in context of a specific class.
|
| 596 |
+
|
| 597 |
+
**Inputs:**
|
| 598 |
+
- `property_name` (string) - e.g., "assigner"
|
| 599 |
+
- `class_name` (string, optional) - e.g., "AdminMetadata"
|
| 600 |
+
|
| 601 |
+
**Returns:** JSON with usage information, examples, and context notes
|
| 602 |
+
|
| 603 |
+
---
|
| 604 |
+
|
| 605 |
+
## π§ Configuration
|
| 606 |
+
|
| 607 |
+
### For Claude Desktop
|
| 608 |
+
|
| 609 |
+
Add to `claude_desktop_config.json`:
|
| 610 |
+
|
| 611 |
+
```json
|
| 612 |
+
{{
|
| 613 |
+
"mcpServers": {{
|
| 614 |
+
"bibframe-docs": {{
|
| 615 |
+
"url": "https://jimfhahn-mcp4bibframe-docs.hf.space/gradio_api/mcp/sse"
|
| 616 |
+
}}
|
| 617 |
+
}}
|
| 618 |
+
}}
|
| 619 |
+
```
|
| 620 |
+
|
| 621 |
+
### For Other MCP Clients
|
| 622 |
+
|
| 623 |
+
Use the SSE endpoint URL above with your MCP client library.
|
| 624 |
+
|
| 625 |
+
---
|
| 626 |
+
|
| 627 |
+
## π Data Source
|
| 628 |
+
|
| 629 |
+
- **BIBFRAME Ontology:** [http://id.loc.gov/ontologies/bibframe.rdf](http://id.loc.gov/ontologies/bibframe.rdf)
|
| 630 |
+
- **Official Documentation:** [https://www.loc.gov/bibframe/](https://www.loc.gov/bibframe/)
|
| 631 |
+
|
| 632 |
+
---
|
| 633 |
+
|
| 634 |
+
## π Related Tools
|
| 635 |
+
|
| 636 |
+
- **SHACL Validator:** [mcp4rdf](https://huggingface.co/spaces/jimfhahn/mcp4rdf)
|
| 637 |
+
- **BIBFRAME Profiles:** [LC BFE Profiles](https://github.com/lcnetdev/bfe-profiles)
|
| 638 |
+
|
| 639 |
+
---
|
| 640 |
+
|
| 641 |
+
*This server automatically loads the latest BIBFRAME ontology on startup.*
|
| 642 |
+
""")
|
| 643 |
|
| 644 |
return demo
|
| 645 |
|