Skip to main content
Glama
paperinvest

Paper MCP Server

by paperinvest

create_portfolio

Generate a new portfolio on Paper's trading platform by specifying account ID, portfolio name, and type (e.g., INDIVIDUAL, IRA). Integrates with AI assistants via the Paper MCP Server for streamlined portfolio management.

Instructions

Create a new portfolio

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountIdYesAccount ID
nameYesPortfolio name
typeYesPortfolio type (e.g., INDIVIDUAL, IRA)

Implementation Reference

  • Handler implementation for the 'create_portfolio' tool. It performs a POST request to the '/accounts/portfolios' API endpoint using the provided arguments.
    case 'create_portfolio':
      response = await api.post('/accounts/portfolios', args);
      break;
  • Tool definition including name, description, and input schema for 'create_portfolio' used in tool listing.
    {
      name: 'create_portfolio',
      description: 'Create a new portfolio',
      inputSchema: {
        type: 'object',
        properties: {
          accountId: { type: 'string', description: 'Account ID' },
          name: { type: 'string', description: 'Portfolio name' },
          type: { type: 'string', description: 'Portfolio type (e.g., INDIVIDUAL, IRA)' }
        },
        required: ['accountId', 'name', 'type']
      }
    },
  • src/index.ts:388-392 (registration)
    Registration of the tools list handler which includes the 'create_portfolio' tool schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return {
        tools
      };
    });
  • src/index.ts:395-565 (registration)
    Registration of the call tool handler which dispatches to the create_portfolio implementation via switch case.
    server.setRequestHandler(CallToolRequestSchema, async (request) => {
      const { name, arguments: args } = request.params;
    
      if (!args) {
        throw new Error('No arguments provided');
      }
    
      try {
        let response;
        
        switch (name) {
          // === ACCOUNT MANAGEMENT ===
          case 'get_account':
            response = await api.get(`/accounts/${args.accountId}`);
            break;
            
          case 'update_account':
            response = await api.put(`/accounts/${args.accountId}`, {
              name: args.name
            });
            break;
            
          case 'freeze_account':
            response = await api.put(`/accounts/${args.accountId}/freeze`);
            break;
    
          // === PORTFOLIO OPERATIONS ===
          case 'create_portfolio':
            response = await api.post('/accounts/portfolios', args);
            break;
            
          case 'get_portfolio':
            response = await api.get(`/accounts/portfolios/${args.portfolioId}`);
            break;
            
          case 'get_account_portfolios':
            response = await api.get(`/accounts/${args.accountId}/portfolios`);
            break;
            
          case 'reset_portfolio':
            response = await api.post(`/accounts/portfolios/${args.portfolioId}/reset`);
            break;
    
          // === POSITIONS ===
          case 'get_portfolio_equities':
            response = await api.get(`/accounts/portfolios/${args.portfolioId}/equities`);
            break;
            
          case 'get_portfolio_options':
            response = await api.get(`/accounts/portfolios/${args.portfolioId}/options`);
            break;
    
          // === TRADING ===
          case 'create_order':
            response = await api.post('/orders', {
              ...args,
              assetClass: args.assetClass || 'EQUITY',
              session: args.session || 'REGULAR',
              timeInForce: args.timeInForce || 'DAY'
            });
            break;
            
          case 'create_batch_orders':
            response = await api.post('/orders/batch', args.orders);
            break;
            
          case 'get_order':
            response = await api.get(`/orders/${args.orderId}`);
            break;
            
          case 'cancel_order':
            response = await api.put(`/orders/${args.orderId}/cancel`);
            break;
            
          case 'get_account_orders':
            response = await api.get(`/orders/account/${args.accountId}`, {
              params: { 
                page: args.page || 1, 
                limit: args.limit || 10 
              }
            });
            break;
            
          case 'cancel_all_account_orders':
            response = await api.delete(`/orders/account/${args.accountId}`);
            break;
            
          case 'get_today_filled_orders':
            response = await api.get('/orders/filled/today', {
              params: {
                page: args.page || 1,
                limit: args.limit || 10
              }
            });
            break;
    
          // === MARKET DATA ===
          case 'get_quote':
            response = await api.get(`/market-data/quote/${args.symbol}`);
            break;
            
          case 'get_batch_quotes':
            response = await api.post('/market-data/quotes/batch', {
              symbols: args.symbols
            });
            break;
            
          case 'get_market_hours':
            if (args.exchange) {
              response = await api.get(`/market-data/market-hours/${args.exchange}`);
            } else {
              response = await api.get('/market-data/market-hours');
            }
            break;
            
          case 'is_market_open':
            response = await api.get(`/market-data/is-market-open/${args.symbol}`);
            break;
    
          // === ACTIVITY LOG ===
          case 'get_portfolio_activities':
            const params: any = {
              page: args.page || 1,
              limit: args.limit || 20
            };
            if (args.category) {
              params.category = args.category;
            }
            response = await api.get(`/activity-log/portfolio/${args.portfolioId}`, { params });
            break;
            
          case 'get_day_trades':
            response = await api.get(`/accounts/portfolios/${args.portfolioId}/day-trades`, {
              params: {
                page: args.page || 1,
                limit: args.limit || 50
              }
            });
            break;
    
          // === MARGIN TRADING ===
          case 'upgrade_to_margin':
            response = await api.put(`/accounts/portfolios/${args.portfolioId}/margin-upgrade`, {
              marginAgreement: args.marginAgreement
            });
            break;
            
          default:
            throw new Error(`Unknown tool: ${name}`);
        }
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(response.data, null, 2)
            }
          ]
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: 'text',
              text: `Error: ${error.message}\n${error.response?.data ? JSON.stringify(error.response.data) : ''}`
            }
          ],
          isError: true
        };
      }
    });
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries full burden. It states 'Create a new portfolio', implying a write/mutation operation, but doesn't disclose behavioral traits such as required permissions, whether it's idempotent, rate limits, or what happens on failure. This is inadequate for a mutation tool with zero annotation coverage.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste. It's appropriately sized and front-loaded, making it easy to parse quickly. Every word earns its place.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity as a mutation operation with no annotations and no output schema, the description is incomplete. It doesn't explain what a portfolio is, the return value, error conditions, or how it integrates with sibling tools. This leaves significant gaps for an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, with all parameters documented in the schema (accountId, name, type). The description adds no additional meaning beyond the schema, such as examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Create a new portfolio' clearly states the verb ('Create') and resource ('portfolio'), but it's vague about what a portfolio entails in this financial context and doesn't distinguish it from sibling tools like 'reset_portfolio' or 'get_portfolio_activities'. It provides basic purpose but lacks specificity.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description offers no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an account first), exclusions, or comparisons to sibling tools like 'update_account' or 'reset_portfolio'. Usage context is implied but not explicit.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/paperinvest/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server