find-person
Locate email addresses by entering a person's name to streamline adding attendees in Microsoft Outlook meeting scheduling using the Microsoft Graph API.
Instructions
Find a person's email address by their name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name or partial name of the person to find |
Implementation Reference
- src/tools/people.ts:10-80 (registration)Registration of the 'find-person' tool using registerTool, including inline schema and handler.registerTool( server, "find-person", "Find a person's email address by their name", { name: z.string().describe("Name or partial name of the person to find"), }, async ({ name }) => { const { graph, userEmail, authError } = await getGraphConfig(); // Check for authentication errors if (authError) { return { content: [ { type: "text", text: `🔐 Authentication Required\n\n${authError}\n\nPlease complete the authentication and try again.`, }, ], }; } // Search for the person by name const people = await graph.searchPeople(name, userEmail); if (!people) { return { content: [ { type: "text", text: "Failed to search for people. Check the logs for details.", }, ], }; } if (people.length === 0) { return { content: [ { type: "text", text: `No people found matching "${name}". Please provide the full email address.`, }, ], }; } // Format the results for response const peopleList = people.map((person: any, index: number) => { const email = person.mail || person.userPrincipalName || person.emailAddresses?.[0]?.address || "No email available"; const displayName = person.displayName || "Unknown name"; return `${index + 1}. ${displayName} (${email})`; }).join("\n"); const successMessage = ` Found ${people.length} people matching "${name}": ${peopleList} You can use these email addresses to create a calendar event.`; return { content: [ { type: "text", text: successMessage, }, ], }; } );
- src/tools/people.ts:14-16 (schema)Input schema for the 'find-person' tool using Zod.{ name: z.string().describe("Name or partial name of the person to find"), },
- src/tools/people.ts:17-79 (handler)Handler function for 'find-person' tool: authenticates, searches for people by name using graph API, formats results.async ({ name }) => { const { graph, userEmail, authError } = await getGraphConfig(); // Check for authentication errors if (authError) { return { content: [ { type: "text", text: `🔐 Authentication Required\n\n${authError}\n\nPlease complete the authentication and try again.`, }, ], }; } // Search for the person by name const people = await graph.searchPeople(name, userEmail); if (!people) { return { content: [ { type: "text", text: "Failed to search for people. Check the logs for details.", }, ], }; } if (people.length === 0) { return { content: [ { type: "text", text: `No people found matching "${name}". Please provide the full email address.`, }, ], }; } // Format the results for response const peopleList = people.map((person: any, index: number) => { const email = person.mail || person.userPrincipalName || person.emailAddresses?.[0]?.address || "No email available"; const displayName = person.displayName || "Unknown name"; return `${index + 1}. ${displayName} (${email})`; }).join("\n"); const successMessage = ` Found ${people.length} people matching "${name}": ${peopleList} You can use these email addresses to create a calendar event.`; return { content: [ { type: "text", text: successMessage, }, ], }; }