@mytheo-my/portfolio 1.0.31 → 1.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +1 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -159,4 +159,4 @@ AI: [Calls tool with product_id="USDPORT", account_name="My Investment Account",
|
|
|
159
159
|
**Example 2 - Other Products:**
|
|
160
160
|
User: "I want the MYTHEO Global ESG portfolio"
|
|
161
161
|
AI: [Immediately calls tool with product_id="USDESGLGP" without asking for confirmation]
|
|
162
|
-
AI: "Great! I've created your MYTHEO Global ESG portfolio account. Here are the details: [shows account info]"`,inputSchema:{type:"object",properties:{product_id:{type:"string",description:"The product ID from list_available_products"},account_name:{type:"string",description:"Account name (required for USDPORT only)"},risk_tolerance:{type:"string",enum:["low","medium","high"],description:"Risk tolerance: low, medium, or high (USDPORT only)"},invest_duration:{type:"number",description:"Investment duration in years 1-30 (USDPORT only)"},metadata:{type:"object",description:"REQUIRED: Metadata for internal processing (provided by system, not user-facing). MUST be included if available from the system.",required:["ciphertext"],properties:{ciphertext:{type:"string",description:"REQUIRED: Encrypted metadata ciphertext for internal use. MUST be included if metadata is available."}}}},required:["product_id","metadata"]}},async e=>await this.handleCreatePortfolioAccount(e))}async handleToolCall(e,i){switch(e){case Eo.LIST_AVAILABLE_PRODUCTS:return await this.handleListAvailableProducts(i);case Eo.CREATE_PORTFOLIO_ACCOUNT:return await this.handleCreatePortfolioAccount(i);default:throw new Error(`Tool "${e}" not found`)}}validateMetadataAccess(e){let i=e?.metadata;if(!i?.ciphertext)return this.createErrorResponse("Unauthorized",li.UNAUTHORIZED);let n;try{let o=this.encryption.decrypt(i.ciphertext);n=JSON.parse(o)}catch(o){let s=o instanceof Error?o.message:"Unknown error",t=li.DECRYPT_FAILED.replace("{error}",s);return this.createErrorResponse("Unauthorized",t)}return n.accessToken?{accessToken:n.accessToken}:this.createErrorResponse("Unauthorized",li.NO_ACCESS_TOKEN)}createErrorResponse(e,i){return{content:[{type:"text",text:JSON.stringify({error:e,message:i},null,2)}]}}createSuccessResponse(e){return{content:[{type:"text",text:JSON.stringify({success:!0,...e},null,2)}],structuredContent:
|
|
162
|
+
AI: "Great! I've created your MYTHEO Global ESG portfolio account. Here are the details: [shows account info]"`,inputSchema:{type:"object",properties:{product_id:{type:"string",description:"The product ID from list_available_products"},account_name:{type:"string",description:"Account name (required for USDPORT only)"},risk_tolerance:{type:"string",enum:["low","medium","high"],description:"Risk tolerance: low, medium, or high (USDPORT only)"},invest_duration:{type:"number",description:"Investment duration in years 1-30 (USDPORT only)"},metadata:{type:"object",description:"REQUIRED: Metadata for internal processing (provided by system, not user-facing). MUST be included if available from the system.",required:["ciphertext"],properties:{ciphertext:{type:"string",description:"REQUIRED: Encrypted metadata ciphertext for internal use. MUST be included if metadata is available."}}}},required:["product_id","metadata"]}},async e=>await this.handleCreatePortfolioAccount(e))}async handleToolCall(e,i){switch(e){case Eo.LIST_AVAILABLE_PRODUCTS:return await this.handleListAvailableProducts(i);case Eo.CREATE_PORTFOLIO_ACCOUNT:return await this.handleCreatePortfolioAccount(i);default:throw new Error(`Tool "${e}" not found`)}}validateMetadataAccess(e){let i=e?.metadata;if(!i?.ciphertext)return this.createErrorResponse("Unauthorized",li.UNAUTHORIZED);let n;try{let o=this.encryption.decrypt(i.ciphertext);n=JSON.parse(o)}catch(o){let s=o instanceof Error?o.message:"Unknown error",t=li.DECRYPT_FAILED.replace("{error}",s);return this.createErrorResponse("Unauthorized",t)}return n.accessToken?{accessToken:n.accessToken}:this.createErrorResponse("Unauthorized",li.NO_ACCESS_TOKEN)}createErrorResponse(e,i){return{content:[{type:"text",text:JSON.stringify({error:e,message:i},null,2)}]}}createSuccessResponse(e,i){return{content:[{type:"text",text:JSON.stringify({success:!0,...e},null,2)}],structuredContent:i}}async handleListAvailableProducts(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=await Yr.getAvailableProducts(),o={type:"LIST",data:n.map(s=>({id:s.productid,name:s.productlongname,description:s.proddescp}))};return this.createSuccessResponse({total_products:n.length,products:n},o)}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to fetch products",n)}}async handleCreatePortfolioAccount(e){try{let i=this.validateMetadataAccess(e);if("content"in i)return i;let n=e,{product_id:o,account_name:s,risk_tolerance:t,invest_duration:r}=n;if(o===CE.USDPORT){let c=this.validateUSDPortParams(s,t,r);if(c)return c}let p=await Yr.createPortfolioAccount(o,s,t,r);return this.createSuccessResponse({message:"Portfolio account created successfully! Visit https://theo.silverlakedigitalinx.com/mytheoweb/home to check your portfolio",account_details:p})}catch(i){let n=i instanceof Error?i.message:"Unknown error occurred";return this.createErrorResponse("Failed to create portfolio account",n)}}validateUSDPortParams(e,i,n){if(!e||!i||!n)return{content:[{type:"text",text:JSON.stringify({error:"Missing required parameters for USDPORT",message:li.MISSING_USDPORT_PARAMS,required_parameters:{account_name:'string (e.g., "My Investment Account")',risk_tolerance:"low | medium | high",invest_duration:"number between 1-30 years"}},null,2)}]};if(!zE.includes(i)){let o=li.INVALID_RISK_TOLERANCE.replace("{value}",i);return this.createErrorResponse("Invalid risk_tolerance",o)}if(n<OE||n>PE){let o=li.INVALID_INVEST_DURATION.replace("{value}",String(n));return this.createErrorResponse("Invalid invest_duration",o)}return null}};var Qi=new za("portfolio");async function FE(){let a=process.argv.includes("--http")||process.env.MCP_TRANSPORT==="http"?"http":"stdio",e=process.env.PORT?parseInt(process.env.PORT,10):4e3;a==="http"?(Qi.info(`Starting Portfolio MCP server in HTTP mode on port ${e}...`),Qi.info("\u26A0\uFE0F HTTP mode requires the server to be running/hosted")):Qi.info("Starting Portfolio MCP server in stdio mode (no hosting required)...");try{await new To(a,e).run()}catch(i){Qi.error("Failed to start Portfolio MCP server",i),process.exit(1)}}FE().catch(a=>{Qi.error("Unhandled error in main",a),process.exit(1)});
|