import{telemetry as r}from"../../../../telemetry/index";import{getUserInfoFromHeaders as s}from"../../utils/jwt";const t="whoami";function c(o,n){o.tool(t,"Get information about the currently authenticated user",()=>{try{const e=s(n||{});return e?(r.sendMcpToolCalledMessage({server_type:"docs",tool:t}),{content:[{type:"text",text:JSON.stringify({email:e.email,name:e.name,subject:e.sub,clientId:e.client_id,scope:e.scope,issuedAt:e.iat?new Date(e.iat*1e3).toISOString():void 0,expiresAt:e.exp?new Date(e.exp*1e3).toISOString():void 0})}],isError:!1}):{content:[{type:"text",text:JSON.stringify({error:"Not authenticated",message:"No valid authentication token found. Please authenticate first."})}],isError:!0}}catch(e){return r.sendMcpErrorMessage({server_type:"docs",tool:t,message:e?.message||"Failed to get user info",stack:e?.stack||""}),{content:[{type:"text",text:JSON.stringify({error:"Failed to get user info",details:e instanceof Error?e.message:String(e)})}],isError:!0}}})}export{c as registerWhoAmITool};
