export const retrievePagePropertyToolDefinition = {
name: 'notion_retrieve_page_property',
description: 'Retrieves a specific property of a Notion page. Use for properties with more than 25 references.',
inputSchema: {
type: 'object',
properties: {
page_id: {
type: 'string',
description: 'The ID of the page'
},
property_id: {
type: 'string',
description: 'The ID of the property to retrieve'
},
page_size: {
type: 'number',
description: 'Number of items to return (max 100)',
minimum: 1,
maximum: 100
},
start_cursor: {
type: 'string',
description: 'Cursor for pagination'
}
},
required: ['page_id', 'property_id']
}
};
export async function handleRetrievePagePropertyTool(client, args) {
try {
const propertyArgs = {
page_id: args.page_id,
property_id: args.property_id,
...(args.page_size && { page_size: args.page_size }),
...(args.start_cursor && { start_cursor: args.start_cursor })
};
const response = await client.retrievePageProperty(propertyArgs);
return {
content: [
{
type: 'text',
text: `Retrieved property: ${args.property_id}\n` +
`Type: ${response.type}\n` +
`Has more: ${'has_more' in response ? response.has_more : false}\n` +
`Next cursor: ${'next_cursor' in response ? response.next_cursor || 'N/A' : 'N/A'}\n` +
`Data: ${JSON.stringify(response, null, 2)}`
}
]
};
}
catch (error) {
return {
content: [
{
type: 'text',
text: `Error retrieving page property: ${error.message || 'Unknown error'}`
}
],
isError: true
};
}
}
export const retrievePagePropertyTool = {
definition: retrievePagePropertyToolDefinition,
handler: handleRetrievePagePropertyTool
};