module
MCP::Tools
Included Modules
Defined in:
mcp/tools.crConstant Summary
-
Log =
::Log.for("mcp") -
NAME_REGEX =
/^([a-zA-Z0-9_-]+|hashtag#[a-zA-Z0-9_-]+|mention@[[email protected]]+)$/ -
TOOL_DEFINITIONS =
[{name: "paginate_collection", description: "Paginate through collections of ActivityPub objects, activities, and actors. Use this tool when you want to inspect the contents of a collection.", properties: [{name: "name", type: "string", description: "Name of the collection to paginate", required: true, matches: NAME_REGEX}, {name: "page", type: "integer", description: "Page number (optional, defaults to 1)", minimum: 1, default: 1}, {name: "size", type: "integer", description: "Number of items per page (optional, defaults to 10, maximum 1000)", minimum: 1, maximum: 20, default: 10}]}, {name: "count_collection_since", description: "Count items in ActivityPub collections since a given time. Use this tool when you want to know if new items have been added in the last day/week/month.", properties: [{name: "name", type: "string", description: "Name of the collection to count", required: true, matches: NAME_REGEX}, {name: "since", type: "time", description: "Time (RFC3339) to count from", required: true}]}, {name: "get_thread", description: "Retrieve thread structure, metadata, and summary data. Large threads may have hundreds of objects, so this tool supports pagination. This tool retrieves the entire thread for the given `object_id` starting at the root, not only the subthread.\n\n**Two Modes of Operation:**\n\n1. **Initial Query Mode**: Provide `object_id` (plus optional `projection` and `page_size`) to start traversing a thread.\n Returns summary data and the first page of objects. If there are more pages, includes a `cursor`.\n\n2. **Pagination Mode**: Provide only `cursor` (from a previous response) to fetch the next page.\n Returns the next page of objects. If there are more pages, includes a `cursor`.\n Do not include `object_id`, `projection`, or `page_size`.\n\n**Usage Examples:**\n- Start: `{\"object_id\": 123, \"projection\": \"metadata\", \"page_size\": 20}`\n- Continue: `{\"cursor\": \"eyJwYWdlcl9pZ...\"}`\n\n**Important:** You must provide EITHER `object_id` OR `cursor`, but not both.", properties: [{name: "object_id", type: "integer", description: "Database ID of any object in the thread. Required for initial query, omit when using cursor.", required: false, minimum: 1}, {name: "projection", type: "string", description: "Data fields to include: 'minimal' (IDs and structure only) or 'metadata' (adds authors, timestamps). Only used with object_id.", required: false, enum: ["minimal", "metadata"], default: "metadata"}, {name: "page_size", type: "integer", description: "Number of objects per page. Only used with object_id.", required: false, minimum: 1, maximum: 100, default: 25}, {name: "cursor", type: "string", description: "Opaque pagination cursor from previous get_thread response. Use ONLY this parameter to fetch next page.", required: false}]}, {name: "analyze_thread", description: "Analyze thread structure and identify key participants and notable branches. Use this before reading thread content to understand the conversation landscape and identify which posts are most relevant to examine. This is especially useful with large threads.\n\n**Returns:**\n- Basic statistics (total posts, unique authors, max depth, analysis duration)\n- Key participants (original poster + top 5 most active posters with their posts)\n- Notable branches (conversation subtrees with ≥5 posts)\n- Timeline histogram (temporal distribution of posts)", properties: [{name: "object_id", type: "integer", description: "Database ID of any object in the thread", required: true, minimum: 1}]}, {name: "read_resources", description: "Read one or more resources by URI (format \"ktistec://{resource}/{id*}\"). Supports all resource types including templated resources (actors, objects) and static resources (information, users). Supports batched reads (comma-separated IDs of resources of the same type). Use this tool as a universal fallback when resources are not supported by an MCP client.", properties: [{name: "uris", type: "array", description: "Resource URIs to read (e.g., ['ktistec://actors/123,456', 'ktistec://objects/456,789'])", required: true, items: "string"}]}] of ToolDefinition
Class Method Summary
- .handle_tool_analyze_thread(params : JSON::Any, account : Account) : JSON::Any
- .handle_tool_count_collection_since(params : JSON::Any, account : Account) : JSON::Any
- .handle_tool_get_thread(params : JSON::Any, account : Account) : JSON::Any
- .handle_tool_paginate_collection(params : JSON::Any, account : Account) : JSON::Any
- .handle_tool_read_resources(params : JSON::Any, account : Account) : JSON::Any
- .handle_tools_call(request : JSON::RPC::Request, account : Account) : JSON::Any
- .handle_tools_list(request : JSON::RPC::Request) : JSON::Any
- .result_pager
- .result_pager=(result_pager)
Macro Summary
-
def_tool(name, description, properties = [] of ToolPropertyDefinition, &block)
Defines an MCP tool.
Macros inherited from module Utils::Paths
activity_path(activity = nil)
activity_path,
actor_path(actor = nil)
actor_path,
actor_relationships_path(actor = nil, relationship = nil)
actor_relationships_path,
actor_remote_follow_path(actor = nil)
actor_remote_follow_path,
admin_accounts_path
admin_accounts_path,
admin_oauth_clients_path
admin_oauth_clients_path,
admin_oauth_tokens_path
admin_oauth_tokens_path,
admin_path
admin_path,
anchor(object = nil)
anchor,
approve_path(object = nil)
approve_path,
back_path
back_path,
block_actor_path(actor = nil)
block_actor_path,
block_object_path(object = nil)
block_object_path,
cancel_fetch_hashtag_path(hashtag = nil)
cancel_fetch_hashtag_path,
cancel_fetch_thread_path(object = nil)
cancel_fetch_thread_path,
clear_translation_object_path(object = nil)
clear_translation_object_path,
create_translation_object_path(object = nil)
create_translation_object_path,
edit_object_path(object = nil)
edit_object_path,
everything_path
everything_path,
filter_path(filter = nil)
filter_path,
filters_path
filters_path,
follow_hashtag_path(hashtag = nil)
follow_hashtag_path,
follow_mention_path(mention = nil)
follow_mention_path,
follow_thread_path(object = nil)
follow_thread_path,
hashtag_path(hashtag = nil)
hashtag_path,
home_path
home_path,
inbox_path(actor = nil)
inbox_path,
mcp_actor_path(actor)
mcp_actor_path,
mcp_information_path
mcp_information_path,
mcp_object_path(object)
mcp_object_path,
mcp_user_path(account)
mcp_user_path,
mention_path(mention = nil)
mention_path,
metrics_path
metrics_path,
object_path(object = nil)
object_path,
object_remote_like_path(object = nil)
object_remote_like_path,
object_remote_reply_path(object = nil)
object_remote_reply_path,
object_remote_share_path(object = nil)
object_remote_share_path,
objects_path
objects_path,
outbox_path(actor = nil)
outbox_path,
refresh_remote_actor_path(actor = nil)
refresh_remote_actor_path,
remote_activity_path(activity = nil)
remote_activity_path,
remote_actor_path(actor = nil)
remote_actor_path,
remote_branch_path(object = nil, anchor = true)
remote_branch_path,
remote_interaction_path
remote_interaction_path,
remote_object_path(object = nil)
remote_object_path,
remote_thread_analysis_path(object = nil)
remote_thread_analysis_path,
remote_thread_path(object = nil, anchor = true)
remote_thread_path,
reply_path(object = nil)
reply_path,
search_path
search_path,
sessions_path
sessions_path,
settings_path
settings_path,
start_fetch_hashtag_path(hashtag = nil)
start_fetch_hashtag_path,
start_fetch_thread_path(object = nil)
start_fetch_thread_path,
system_path
system_path,
tasks_path
tasks_path,
thread_path(object = nil, anchor = true)
thread_path,
unapprove_path(object = nil)
unapprove_path,
unblock_actor_path(actor = nil)
unblock_actor_path,
unblock_object_path(object = nil)
unblock_object_path,
unfollow_hashtag_path(hashtag = nil)
unfollow_hashtag_path,
unfollow_mention_path(mention = nil)
unfollow_mention_path,
unfollow_thread_path(object = nil)
unfollow_thread_path
Class Method Detail
Macro Detail
Defines an MCP tool.
Arguments:
- name: Tool name
- description: Tool description
- properties: Array of ToolPropertyDefinition (type, description, required, etc.)
- block: Tool implementation
The block can access validated parameters via arguments["param_name"]?
and must return JSON::Any.