Main Page: Difference between revisions

From Public AI Wiki
No edit summary
No edit summary
Line 15: Line 15:
* '''Crisis Support''': Get current hotline numbers and resources for mental health emergencies
* '''Crisis Support''': Get current hotline numbers and resources for mental health emergencies
* '''Transit Information''': Real-time public transportation schedules and routes
* '''Transit Information''': Real-time public transportation schedules and routes
* '''Events & Activities''': Discover upcoming community events and festivals
* '''Location Services''': Search for places and get geographic information
* '''Location Services''': Search for places and get geographic information
* '''And more...''': Any information that benefits from being current, localized, and structured
* '''And more...''': Any information that benefits from being current, localized, and structured
Line 30: Line 31:
|-
|-
| '''Examples:'''
| '''Examples:'''
* [[Tool:SuicideHotline]] - Hotline numbers in ToolResources
* [[Tool:SuicideHotline]] - Crisis hotlines with custom SuicideHotlineResource template
* [[Tool:UpcomingBTO]] - BTO details in page content
* [[Tool:UpcomingEvents]] - Events with custom UpcomingEventsResource template
| '''Examples:'''
| '''Examples:'''
* Swiss Transit - Calls transport.opendata.ch API
* Swiss Transit - Calls transport.opendata.ch API
* OSM Nominatim - Searches OpenStreetMap
* Singapore Carparks - Queries data.gov.sg API
|-
|-
| '''Who can contribute:''' Anyone (no coding required)
| '''Who can contribute:''' Anyone (no coding required)
Line 43: Line 44:
* Information that changes over time
* Information that changes over time
* Data that needs community verification
* Data that needs community verification
* Custom data structures per tool
| '''Best for:'''
| '''Best for:'''
* Real-time API integrations
* Real-time API integrations
Line 55: Line 57:
|fields=_pageName=Tool,description,community,has_resources
|fields=_pageName=Tool,description,community,has_resources
|order by=_pageName
|order by=_pageName
|format=table
|headers show
}}
== Recent Resources ==
{{#cargo_query:
tables=ToolResources
|fields=_pageName=Resource,country,tool
|order by=last_verified DESC
|limit=10
|format=table
|format=table
|headers show
|headers show
Line 74: Line 65:
Choose your contribution pathway based on what you want to do:
Choose your contribution pathway based on what you want to do:


=== 1️⃣ Improve a Wiki Tool ===
=== 1️⃣ Add Data to an Existing Tool ===


'''Add or update localized data for an existing tool'''
'''Add or update localized data for an existing tool'''
Line 82: Line 73:
'''Perfect for:'''
'''Perfect for:'''
* Adding suicide hotline numbers for your country
* Adding suicide hotline numbers for your country
* Updating BTO launch information
* Contributing upcoming events in your region
* Contributing local crisis resources
* Adding local crisis resources
* Verifying and updating existing information
* Verifying and updating existing information


'''Quick start:'''
'''Quick start:'''
# Browse the tools above and find one with <code>has_resources=true</code>
# Browse the tools above and find one with <code>has_resources=true</code>
# Create a page: <code>Resource:ToolName/YourLocation</code>
# Check the tool's page for its custom resource template (e.g., [[Template:SuicideHotlineResource]], [[Template:UpcomingEventsResource]])
# Use the [[Template:ToolResource]] template
# Create or edit a page: <code>Resource:ToolName/YourLocation</code>
# Fill in your local data (phone numbers, websites, etc.)
# Use the tool's specific resource template with the appropriate fields
# Save and done!
# Fill in your local data and save!


'''💡 For technically-minded contributors:''' You can set up automations (GitHub Actions, cron jobs) to periodically update wiki data via the MediaWiki API.
'''💡 Tip:''' Look at existing resources for that tool to see what fields are available and how to format your data.


----
----


=== 2️⃣ Add a New Wiki Tool ===
=== 2️⃣ Create a New Wiki Tool ===


'''Create a new tool where community members can contribute data'''
'''Design a new tool with a custom data structure'''


'''Difficulty:''' Easy to Medium
'''Difficulty:''' Medium


'''When to use this:'''
'''When to use this:'''
* You have location-specific data that communities can maintain
* You have location-specific data that communities can maintain
* The information doesn't require API calls
* The information doesn't require API calls
* You need a specific data structure for your use case
* Multiple people can verify and update the information
* Multiple people can verify and update the information


'''Quick start:'''
'''Step-by-step guide:'''
# Create a page: <code>Tool:YourToolName</code>
 
# Use the [[Template:Tool]] template
'''Step 1: Design Your Resource Template'''
# Set <code>has_resources=true</code> if you'll add location-specific data
 
# Add your first resources (see option #1 above)
Create a page: <code>Template:YourToolNameResource</code>
# The tool is now available to AI assistants!
 
This template defines what data your tool collects. Each tool has complete freedom to define its own fields!
 
'''Example:''' Library Hours Resource Template
<pre>
<noinclude>
This template stores library operating hours by location.
 
{{#cargo_declare:
_table=LibraryHoursResources
|tool=Page
|country=String
|region=String
|library_name=String
|weekday_hours=String
|weekend_hours=String
|holiday_hours=String
|phone=String
|website=URL
|last_verified=Date
}}
 
== Parameters ==
* '''tool''' - The tool page (should be "Tool:LibraryHours")
* '''country''' - Country name
* '''region''' - Region/state within country
* '''library_name''' - Name of the library
* '''weekday_hours''' - Operating hours Monday-Friday
* '''weekend_hours''' - Operating hours Saturday-Sunday
* '''holiday_hours''' - Special holiday hours
* '''phone''' - Contact phone number
* '''website''' - Library website URL
* '''last_verified''' - Date information was verified (YYYY-MM-DD)
 
[[Category:Templates]]
</noinclude>
<includeonly>
{| class="wikitable" style="width:100%;"
! colspan="2" | {{{library_name}}} - {{{country}}}{{#if:{{{region|}}}| ({{{region}}})}}
|-
| '''Weekday Hours''' || {{{weekday_hours}}}
|-
| '''Weekend Hours''' || {{{weekend_hours}}}
|-
{{#if:{{{holiday_hours|}}}|
{{!}} '''Holiday Hours''' {{!}}{{!}} {{{holiday_hours}}}
{{!}}-
|}}
| '''Phone''' || {{{phone}}}
|-
| '''Website''' || [{{{website}}} Visit website]
|}
 
{{#cargo_store:
_table=LibraryHoursResources
|tool={{{tool}}}
|country={{{country}}}
|region={{{region}}}
|library_name={{{library_name}}}
|weekday_hours={{{weekday_hours}}}
|weekend_hours={{{weekend_hours}}}
|holiday_hours={{{holiday_hours}}}
|phone={{{phone}}}
|website={{{website}}}
|last_verified={{{last_verified}}}
}}
</includeonly>
</pre>
 
'''Key parts:'''
* '''<code>_table</code>''': Must be <code>YourToolNameResources</code> (this is important for the MCP server!)
* '''Field definitions''': Define all fields your tool needs with their types (String, Date, URL, Text, etc.)
* '''Display template''': Create a nice visual display for the data
* '''<code>cargo_store</code>''': Saves the data to the Cargo database
 
'''Step 2: Create the Tool Page'''
 
Create a page: <code>Tool:YourToolName</code>
 
<pre>
{{Tool
|name=Library Hours
|description=Operating hours for public libraries by location
|community=Singapore
|has_resources=true
|resource_table=LibraryHoursResources
|overview=Provides current operating hours for public libraries, including weekday, weekend, and holiday schedules.
|usage=Query by library name or location to get current hours. All times are in local timezone.
}}
 
== About This Tool ==
 
This tool provides up-to-date operating hours for public libraries. Information is maintained by community contributors and library staff.
 
== Contributing ==
 
To add library hours for your location:
# Create a page: <code>Resource:LibraryHours/YourLocation</code>
# Use the {{tl|LibraryHoursResource}} template
# Verify hours from official library websites
# Update the last_verified date
 
== See Also ==
* [[Template:LibraryHoursResource]] - Template for adding library hours
 
[[Category:Tools]]
[[Category:Community]]
</pre>
 
'''Important fields:'''
* <code>has_resources=true</code> - Indicates this tool uses resources
* <code>resource_table=YourToolNameResources</code> - Must match your template's _table name
 
'''Step 3: Create Your First Resource'''
 
Create a page: <code>Resource:YourToolName/Location</code>
 
Use your new template to add the first resource!
 
'''Step 4: Update Cargo Tables'''


'''Example tools to create:'''
Critical step - makes your data queryable:
* Public Library Hours (by location)
# Go to [[Special:CargoTables]]
* Community Event Calendars
# Find your new table (e.g., <code>LibraryHoursResources</code>)
* Local Government Service Contact Info
# Click "Recreate data"
* Emergency Services by Region
# Your tool is now live!


----
----
Line 135: Line 246:


'''Quick start:'''
'''Quick start:'''
# Fork the [https://github.com/forpublicai/publicai-mcp-server repository]
# Fork the [https://github.com/forpublicai/pai-mcp-server repository]
# Add your <code>@mcp.tool()</code> function to <code>main.py</code>
# Add your <code>@mcp.tool()</code> function to <code>main.py</code>
# Test locally
# Test locally with <code>python main.py</code>
# Submit a Pull Request
# Submit a Pull Request


Line 154: Line 265:
! Use this pathway
! Use this pathway
|-
|-
| Add data for an existing tool
| Add data to an existing tool
| <span style="font-size: 1.2em;">1️⃣</span> Improve a Wiki Tool
| <span style="font-size: 1.2em;">1️⃣</span> Add Data to an Existing Tool
|-
|-
| Create a tool with community-maintainable data
| Create a tool with custom data fields
| <span style="font-size: 1.2em;">2️⃣</span> Add a New Wiki Tool
| <span style="font-size: 1.2em;">2️⃣</span> Create a New Wiki Tool
|-
|-
| Build an API integration or complex tool
| Build an API integration or complex tool
Line 166: Line 277:
----
----


== Detailed Templates & Examples ==
== Detailed Examples ==
 
=== Example: Adding a Suicide Hotline Resource ===


=== Adding a Wiki Tool Resource ===
The [[Tool:SuicideHotline]] uses [[Template:SuicideHotlineResource]] which has fields for:
* Multiple phone numbers (primary, secondary, youth hotline)
* Text services (SMS, WhatsApp)
* Online chat URLs
* Emergency services
* Languages supported
* Operating hours


Create a page: <code>Resource:ToolName/Location</code>
Create a page: <code>Resource:SuicideHotline/YourCountry</code>


'''Example:''' Adding US suicide hotline
<pre>
<pre>
{{ToolResource
{{SuicideHotlineResource
|tool=Tool:SuicideHotline
|tool=Tool:SuicideHotline
|country=United States
|country=United States
|region=National
|primary_phone=988
|data_field1_name=Phone
|primary_phone_description=National Suicide Prevention Lifeline - 24/7 support
|data_field1_value=988 (Suicide & Crisis Lifeline, 24/7)
|text_service=Text "HELLO" to 741741
|data_field2_name=Text Service
|text_service_description=Crisis Text Line - 24/7 text support
|data_field2_value=Text "HELLO" to 741741 (Crisis Text Line)
|online_chat_url=https://988lifeline.org/chat
|data_field3_name=Online Chat
|online_chat_description=Online chat available 24/7
|data_field3_value=https://988lifeline.org/chat
|languages=English, Spanish
|additional_info=Free and confidential support. Services available in English and Spanish.
|availability=24/7
|additional_info=Free and confidential. Veterans can press 1 for specialized support.
|last_verified=2025-12-26
|last_verified=2025-12-26
}}
}}
</pre>
</pre>


=== Creating a New Wiki Tool ===
=== Example: Adding an Upcoming Event ===
 
The [[Tool:UpcomingEvents]] uses [[Template:UpcomingEventsResource]] which has fields for:
* Event name and type
* Start and end dates
* Venue and address
* Admission details
* Event description
* Registration URL


Create a page: <code>Tool:YourToolName</code>
Create a page: <code>Resource:UpcomingEvents/Singapore</code>


'''Example:''' Public Library Hours
<pre>
<pre>
{{Tool
{{UpcomingEventsResource
|name=Public Library Hours
|tool=Tool:UpcomingEvents
|description=Operating hours for public libraries by location
|country=Singapore
|community=Singapore
|event_name=Singapore Art Week 2026
|has_resources=true
|event_type=Cultural
|overview=Provides current operating hours for public libraries across Singapore, including special hours for holidays and events.
|start_date=2026-01-10
|usage=Query by library name or region to get current hours.
|end_date=2026-01-18
|venue=Multiple locations across Singapore
|address=Various galleries and museums
|admission=Mixed (some free, some ticketed)
|description=Annual celebration of visual arts with exhibitions, talks, and workshops
|registration_url=https://www.artweek.sg
|last_verified=2025-12-26
}}
 
{{UpcomingEventsResource
|tool=Tool:UpcomingEvents
|country=Singapore
|event_name=National Day Parade 2026
|event_type=National Celebration
|start_date=2026-08-09
|venue=Marina Bay Floating Platform
|admission=Free (ballot required)
|description=Singapore's National Day celebration with parade and fireworks
|last_verified=2025-12-26
}}
}}
</pre>
</pre>


Then add resources for each library location.
Note: You can add multiple resources to the same page!


=== Important: Updating Cargo Tables ===
== How Resource Templates Work ==


After adding or editing wiki tools/resources:
Each tool defines its own resource template with exactly the fields it needs:
# Navigate to [[Special:CargoTables]]
 
# Find the relevant table (Tools or ToolResources)
{| class="wikitable"
# Click "Recreate" to update the database
! Tool
# Your changes are now live!
! Template
! Custom Fields
|-
| [[Tool:SuicideHotline]]
| [[Template:SuicideHotlineResource]]
| primary_phone, secondary_phone, text_service, online_chat_url, youth_hotline, emergency_services, languages, availability
|-
| [[Tool:UpcomingEvents]]
| [[Template:UpcomingEventsResource]]
| event_name, event_type, start_date, end_date, venue, address, admission, description, registration_url
|-
| Your tool!
| [[Template:YourToolResource]]
| Whatever fields you need!
|}
 
This gives tool creators complete flexibility to structure their data appropriately.


== Guidelines ==
== Guidelines ==
Line 220: Line 380:


* '''Accuracy''': All information must be current and verified
* '''Accuracy''': All information must be current and verified
* '''Verification''': Always include a '''last_verified''' date
* '''Verification''': Always include a <code>last_verified</code> date
* '''Completeness''': Provide all relevant contact methods (phone, text, online)
* '''Completeness''': Fill in all relevant fields for your resource
* '''Localization''': Information should be specific to the country/region
* '''Localization''': Information should be specific to the country/region
* '''Neutrality''': Present information objectively without bias
* '''Neutrality''': Present information objectively without bias
Line 228: Line 388:


✅ '''Good candidates for Wiki Tools:'''
✅ '''Good candidates for Wiki Tools:'''
* Information that changes over time (phone numbers, schedules)
* Information that changes over time (phone numbers, schedules, events)
* Localized data (country/region-specific resources)
* Localized data (country/region-specific resources)
* Public services (hotlines, transit, emergency services)
* Public services (hotlines, transit, emergency services, events)
* Data that AI assistants frequently need but may not have current info on
* Data that AI assistants frequently need but may not have current info on
* Information that benefits from community verification


❌ '''Not appropriate:'''
❌ '''Not appropriate:'''
Line 238: Line 399:
* Information that rarely changes and is well-known (e.g., historical facts)
* Information that rarely changes and is well-known (e.g., historical facts)
* Opinion pieces or subjective content
* Opinion pieces or subjective content
* Time-sensitive data that changes by the minute (use MCP tools with APIs instead)


== Technical Documentation ==
== Technical Documentation ==
Line 248: Line 410:
* '''FastMCP Server''': Exposes wiki data as MCP tools for AI assistants
* '''FastMCP Server''': Exposes wiki data as MCP tools for AI assistants


'''Repository:''' [https://github.com/yourusername/pai-mcp-server pai-mcp-server]
'''Repository:''' [https://github.com/forpublicai/pai-mcp-server pai-mcp-server]
 
=== How the MCP Server Works ===
 
The MCP server provides three main functions for wiki tools:
 
'''1. list_tools_by_community(community)'''
* Lists all tools available for a community
* Queries the Tools table
 
'''2. use_tool(tool, country, region=None)'''
* Retrieves resources for a specific tool and location
* Automatically discovers the resource table structure using the Cargo API
* Works with any tool's custom resource template
* Example: <code>use_tool("SuicideHotline", "Singapore")</code>
 
'''3. add_resource(tool, country, resource_data, region=None)'''
* Adds a new resource to a tool's resource page
* Validates fields against the tool's resource table schema
* Safely prepends content without overwriting existing data
* Example: <code>add_resource("UpcomingEvents", "Singapore", {"event_name": "Art Fair", "start_date": "2026-03-15", ...})</code>
 
The server uses <code>cargofields</code> API to dynamically discover each tool's schema, so it works with any custom resource template!
 
=== Naming Conventions (Important!) ===
 
For the MCP server to work correctly with your tool:
 
* '''Tool page:''' <code>Tool:YourToolName</code>
* '''Resource template:''' <code>Template:YourToolNameResource</code>
* '''Cargo table:''' <code>YourToolNameResources</code> (defined in template's <code>_table</code>)
* '''Resource pages:''' <code>Resource:YourToolName/Location</code>
 
The server automatically derives table and template names from the tool name, so consistency is critical!


=== API Access ===
=== API Access ===
Line 254: Line 449:
Data can be queried via:
Data can be queried via:
* '''MediaWiki API''': Standard MediaWiki API endpoints (<code>https://wiki.publicai.co/w/api.php</code>)
* '''MediaWiki API''': Standard MediaWiki API endpoints (<code>https://wiki.publicai.co/w/api.php</code>)
* '''Cargo API''': Special:CargoQuery for structured queries
* '''Cargo API''': Query structured data using <code>action=cargoquery</code>
* '''Cargo Fields API''': Discover table schemas using <code>action=cargofields</code>
* '''MCP Server''': FastMCP server provides simplified access for AI assistants
* '''MCP Server''': FastMCP server provides simplified access for AI assistants


Line 262: Line 458:
* [[Special:CargoTables|View all Cargo tables]]
* [[Special:CargoTables|View all Cargo tables]]
* '''Tools''' table: Stores all tool definitions
* '''Tools''' table: Stores all tool definitions
* '''ToolResources''' table: Stores locale-specific resource data
* '''[ToolName]Resources''' tables: Each tool has its own resource table with custom fields
 
'''After editing resources:''' Remember to recreate the Cargo table data at [[Special:CargoTables]] to make your changes queryable!


== Need Help? ==
== Need Help? ==


* '''Wiki editing''': [[Template:Tool|Tool Template]] | [[Template:ToolResource|Resource Template]]
* '''Creating templates''': Study [[Template:SuicideHotlineResource|SuicideHotlineResource]] or [[Template:UpcomingEventsResource|UpcomingEventsResource]] as examples
* '''Cargo tables''': [[Special:CargoTables|Manage Tables]]
* '''Cargo tables''': [[Special:CargoTables|Manage Tables]]
* '''Questions''': Open an issue in the repository
* '''MCP Server''': [https://github.com/forpublicai/pai-mcp-server GitHub Repository]
* '''Questions''': Open an issue in the repository or ask in discussions


== Examples to Learn From ==
== Examples to Learn From ==


'''Good Wiki Tools:'''
'''Well-designed Wiki Tools:'''
* [[Tool:SuicideHotline]] - Clean resource structure with multiple countries
* [[Tool:SuicideHotline]] - Crisis resources with rich custom template
* [[Tool:UpcomingBTO]] - Rich page content that updates regularly
* [[Tool:UpcomingEvents]] - Events with date fields and venue information
 
'''Well-structured Resources:'''
* [[Resource:SuicideHotline/Singapore]] - Complete fields, multiple contact methods
* [[Resource:UpcomingEvents/Singapore]] - Multiple events on one page


'''Good Resources to Study:'''
'''Good Templates to Study:'''
* [[Resource:SuicideHotline/Singapore]] - Well-structured with all fields
* [[Template:SuicideHotlineResource]] - Complex template with many field types
* [[Resource:SuicideHotline/Switzerland]] - Multiple contact methods
* [[Template:UpcomingEventsResource]] - Date handling and optional fields




[[Category:Public AI]]
[[Category:Public AI]]

Revision as of 08:24, 26 December 2025

Public AI is a structured knowledge base of tools and resources that AI assistants can access programmatically to help users with real-world tasks.

What is Public AI?

Public AI serves as a bridge between AI assistants (like Claude, ChatGPT, etc.) and real-world information that users need. Instead of AI assistants having outdated or incomplete information, they can query this wiki to get current, accurate, and localized data.

How It Works

  1. Structured Data: Information is stored using MediaWiki's Cargo extension, making it queryable like a database
  2. MCP Server: A FastMCP server reads from this wiki and exposes the data as tools that AI assistants can use
  3. AI Integration: When you ask an AI assistant a question (e.g., "What's the suicide hotline in Singapore?"), it queries this wiki and gives you current information

Use Cases

  • Crisis Support: Get current hotline numbers and resources for mental health emergencies
  • Transit Information: Real-time public transportation schedules and routes
  • Events & Activities: Discover upcoming community events and festivals
  • Location Services: Search for places and get geographic information
  • And more...: Any information that benefits from being current, localized, and structured

Understanding Public AI Tools

Public AI has two types of tools, each serving different purposes:

Wiki Tools MCP Tools
Data lives in this wiki
The MCP server reads and serves wiki content to AI assistants
Code lives in GitHub repository
Python functions that integrate with external APIs
Examples: Examples:
  • Swiss Transit - Calls transport.opendata.ch API
  • Singapore Carparks - Queries data.gov.sg API
Who can contribute: Anyone (no coding required) Who can contribute: Developers (Python required)
Best for:
  • Location-specific resources
  • Information that changes over time
  • Data that needs community verification
  • Custom data structures per tool
Best for:
  • Real-time API integrations
  • Complex data processing
  • External service connections

Browse All Tools

Tool description community has resources
Tool:SuicideHotline International suicide prevention hotlines and crisis support resources Singapore Switzerland Yes
Tool:UpcomingBTO Upcoming Build-To-Order (BTO) public housing launches in Singapore Singapore Yes
Tool:UpcomingEvents Community and public events happening in various locations Singapore Yes

How to Contribute

Choose your contribution pathway based on what you want to do:

1️⃣ Add Data to an Existing Tool

Add or update localized data for an existing tool

Difficulty: Easy (no coding required)

Perfect for:

  • Adding suicide hotline numbers for your country
  • Contributing upcoming events in your region
  • Adding local crisis resources
  • Verifying and updating existing information

Quick start:

  1. Browse the tools above and find one with has_resources=true
  2. Check the tool's page for its custom resource template (e.g., Template:SuicideHotlineResource, Template:UpcomingEventsResource)
  3. Create or edit a page: Resource:ToolName/YourLocation
  4. Use the tool's specific resource template with the appropriate fields
  5. Fill in your local data and save!

💡 Tip: Look at existing resources for that tool to see what fields are available and how to format your data.


2️⃣ Create a New Wiki Tool

Design a new tool with a custom data structure

Difficulty: Medium

When to use this:

  • You have location-specific data that communities can maintain
  • The information doesn't require API calls
  • You need a specific data structure for your use case
  • Multiple people can verify and update the information

Step-by-step guide:

Step 1: Design Your Resource Template

Create a page: Template:YourToolNameResource

This template defines what data your tool collects. Each tool has complete freedom to define its own fields!

Example: Library Hours Resource Template

<noinclude>
This template stores library operating hours by location.

{{#cargo_declare:
_table=LibraryHoursResources
|tool=Page
|country=String
|region=String
|library_name=String
|weekday_hours=String
|weekend_hours=String
|holiday_hours=String
|phone=String
|website=URL
|last_verified=Date
}}

== Parameters ==
* '''tool''' - The tool page (should be "Tool:LibraryHours")
* '''country''' - Country name
* '''region''' - Region/state within country
* '''library_name''' - Name of the library
* '''weekday_hours''' - Operating hours Monday-Friday
* '''weekend_hours''' - Operating hours Saturday-Sunday
* '''holiday_hours''' - Special holiday hours
* '''phone''' - Contact phone number
* '''website''' - Library website URL
* '''last_verified''' - Date information was verified (YYYY-MM-DD)

[[Category:Templates]]
</noinclude>
<includeonly>
{| class="wikitable" style="width:100%;"
! colspan="2" | {{{library_name}}} - {{{country}}}{{#if:{{{region|}}}| ({{{region}}})}}
|-
| '''Weekday Hours''' || {{{weekday_hours}}}
|-
| '''Weekend Hours''' || {{{weekend_hours}}}
|-
{{#if:{{{holiday_hours|}}}|
{{!}} '''Holiday Hours''' {{!}}{{!}} {{{holiday_hours}}}
{{!}}-
|}}
| '''Phone''' || {{{phone}}}
|-
| '''Website''' || [{{{website}}} Visit website]
|}

{{#cargo_store:
_table=LibraryHoursResources
|tool={{{tool}}}
|country={{{country}}}
|region={{{region}}}
|library_name={{{library_name}}}
|weekday_hours={{{weekday_hours}}}
|weekend_hours={{{weekend_hours}}}
|holiday_hours={{{holiday_hours}}}
|phone={{{phone}}}
|website={{{website}}}
|last_verified={{{last_verified}}}
}}
</includeonly>

Key parts:

  • _table: Must be YourToolNameResources (this is important for the MCP server!)
  • Field definitions: Define all fields your tool needs with their types (String, Date, URL, Text, etc.)
  • Display template: Create a nice visual display for the data
  • cargo_store: Saves the data to the Cargo database

Step 2: Create the Tool Page

Create a page: Tool:YourToolName

{{Tool
|name=Library Hours
|description=Operating hours for public libraries by location
|community=Singapore
|has_resources=true
|resource_table=LibraryHoursResources
|overview=Provides current operating hours for public libraries, including weekday, weekend, and holiday schedules.
|usage=Query by library name or location to get current hours. All times are in local timezone.
}}

== About This Tool ==

This tool provides up-to-date operating hours for public libraries. Information is maintained by community contributors and library staff.

== Contributing ==

To add library hours for your location:
# Create a page: <code>Resource:LibraryHours/YourLocation</code>
# Use the {{tl|LibraryHoursResource}} template
# Verify hours from official library websites
# Update the last_verified date

== See Also ==
* [[Template:LibraryHoursResource]] - Template for adding library hours

[[Category:Tools]]
[[Category:Community]]

Important fields:

  • has_resources=true - Indicates this tool uses resources
  • resource_table=YourToolNameResources - Must match your template's _table name

Step 3: Create Your First Resource

Create a page: Resource:YourToolName/Location

Use your new template to add the first resource!

Step 4: Update Cargo Tables

Critical step - makes your data queryable:

  1. Go to Special:CargoTables
  2. Find your new table (e.g., LibraryHoursResources)
  3. Click "Recreate data"
  4. Your tool is now live!

3️⃣ Add a New MCP Tool

Implement a Python tool that integrates with external APIs

Difficulty: Advanced (requires Python/coding)

When to use this:

  • You need to call external APIs (weather, transit, etc.)
  • The tool requires real-time data
  • Complex logic or data transformation is needed

Quick start:

  1. Fork the repository
  2. Add your @mcp.tool() function to main.py
  3. Test locally with python main.py
  4. Submit a Pull Request

Example tools to create:

  • Weather API integrations
  • Stock market data
  • Real-time transit for other countries
  • News aggregators

Quick Decision Guide

I want to... Use this pathway
Add data to an existing tool 1️⃣ Add Data to an Existing Tool
Create a tool with custom data fields 2️⃣ Create a New Wiki Tool
Build an API integration or complex tool 3️⃣ Add a New MCP Tool

Detailed Examples

Example: Adding a Suicide Hotline Resource

The Tool:SuicideHotline uses Template:SuicideHotlineResource which has fields for:

  • Multiple phone numbers (primary, secondary, youth hotline)
  • Text services (SMS, WhatsApp)
  • Online chat URLs
  • Emergency services
  • Languages supported
  • Operating hours

Create a page: Resource:SuicideHotline/YourCountry

{{SuicideHotlineResource
|tool=Tool:SuicideHotline
|country=United States
|primary_phone=988
|primary_phone_description=National Suicide Prevention Lifeline - 24/7 support
|text_service=Text "HELLO" to 741741
|text_service_description=Crisis Text Line - 24/7 text support
|online_chat_url=https://988lifeline.org/chat
|online_chat_description=Online chat available 24/7
|languages=English, Spanish
|availability=24/7
|additional_info=Free and confidential. Veterans can press 1 for specialized support.
|last_verified=2025-12-26
}}

Example: Adding an Upcoming Event

The Tool:UpcomingEvents uses Template:UpcomingEventsResource which has fields for:

  • Event name and type
  • Start and end dates
  • Venue and address
  • Admission details
  • Event description
  • Registration URL

Create a page: Resource:UpcomingEvents/Singapore

{{UpcomingEventsResource
|tool=Tool:UpcomingEvents
|country=Singapore
|event_name=Singapore Art Week 2026
|event_type=Cultural
|start_date=2026-01-10
|end_date=2026-01-18
|venue=Multiple locations across Singapore
|address=Various galleries and museums
|admission=Mixed (some free, some ticketed)
|description=Annual celebration of visual arts with exhibitions, talks, and workshops
|registration_url=https://www.artweek.sg
|last_verified=2025-12-26
}}

{{UpcomingEventsResource
|tool=Tool:UpcomingEvents
|country=Singapore
|event_name=National Day Parade 2026
|event_type=National Celebration
|start_date=2026-08-09
|venue=Marina Bay Floating Platform
|admission=Free (ballot required)
|description=Singapore's National Day celebration with parade and fireworks
|last_verified=2025-12-26
}}

Note: You can add multiple resources to the same page!

How Resource Templates Work

Each tool defines its own resource template with exactly the fields it needs:

Tool Template Custom Fields
Tool:SuicideHotline Template:SuicideHotlineResource primary_phone, secondary_phone, text_service, online_chat_url, youth_hotline, emergency_services, languages, availability
Tool:UpcomingEvents Template:UpcomingEventsResource event_name, event_type, start_date, end_date, venue, address, admission, description, registration_url
Your tool! Template:YourToolResource Whatever fields you need!

This gives tool creators complete flexibility to structure their data appropriately.

Guidelines

Quality Standards

  • Accuracy: All information must be current and verified
  • Verification: Always include a last_verified date
  • Completeness: Fill in all relevant fields for your resource
  • Localization: Information should be specific to the country/region
  • Neutrality: Present information objectively without bias

What Belongs Here

Good candidates for Wiki Tools:

  • Information that changes over time (phone numbers, schedules, events)
  • Localized data (country/region-specific resources)
  • Public services (hotlines, transit, emergency services, events)
  • Data that AI assistants frequently need but may not have current info on
  • Information that benefits from community verification

Not appropriate:

  • Personal or private information
  • Copyrighted content without permission
  • Information that rarely changes and is well-known (e.g., historical facts)
  • Opinion pieces or subjective content
  • Time-sensitive data that changes by the minute (use MCP tools with APIs instead)

Technical Documentation

For Developers

This wiki uses:

  • MediaWiki: The underlying wiki platform
  • Cargo Extension: Structured data storage and querying
  • FastMCP Server: Exposes wiki data as MCP tools for AI assistants

Repository: pai-mcp-server

How the MCP Server Works

The MCP server provides three main functions for wiki tools:

1. list_tools_by_community(community)

  • Lists all tools available for a community
  • Queries the Tools table

2. use_tool(tool, country, region=None)

  • Retrieves resources for a specific tool and location
  • Automatically discovers the resource table structure using the Cargo API
  • Works with any tool's custom resource template
  • Example: use_tool("SuicideHotline", "Singapore")

3. add_resource(tool, country, resource_data, region=None)

  • Adds a new resource to a tool's resource page
  • Validates fields against the tool's resource table schema
  • Safely prepends content without overwriting existing data
  • Example: add_resource("UpcomingEvents", "Singapore", {"event_name": "Art Fair", "start_date": "2026-03-15", ...})

The server uses cargofields API to dynamically discover each tool's schema, so it works with any custom resource template!

Naming Conventions (Important!)

For the MCP server to work correctly with your tool:

  • Tool page: Tool:YourToolName
  • Resource template: Template:YourToolNameResource
  • Cargo table: YourToolNameResources (defined in template's _table)
  • Resource pages: Resource:YourToolName/Location

The server automatically derives table and template names from the tool name, so consistency is critical!

API Access

Data can be queried via:

  • MediaWiki API: Standard MediaWiki API endpoints (https://wiki.publicai.co/w/api.php)
  • Cargo API: Query structured data using action=cargoquery
  • Cargo Fields API: Discover table schemas using action=cargofields
  • MCP Server: FastMCP server provides simplified access for AI assistants

Cargo Tables

View and manage the structured data:

  • View all Cargo tables
  • Tools table: Stores all tool definitions
  • [ToolName]Resources tables: Each tool has its own resource table with custom fields

After editing resources: Remember to recreate the Cargo table data at Special:CargoTables to make your changes queryable!

Need Help?

Examples to Learn From

Well-designed Wiki Tools:

Well-structured Resources:

Good Templates to Study: