← All connections

Connect to Aplicações próprias

Your own application talking MCP directly to NewAlgorithm — TypeScript, Python or plain HTTP.

Before you start, create your free account.Create account

Which MCP will you connect? The commands below change according to your choice.

  1. 1

    Generate your API key

    Sign in to app.newalgorithm.io with your account, open Keys & apps and generate a key. It is shown only once: copy it and store it somewhere safe.

    Key format
    na_live_xxxxxxxxxxxxxxxxx
  2. 2

    TypeScript — official SDK

    Install with npm install @modelcontextprotocol/sdk and connect:

    TypeScript
    import { Client } from "@modelcontextprotocol/sdk/client/index.js"
    import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
    
    const transport = new StreamableHTTPClientTransport(new URL("https://totvs.mcp.newalgorithm.io/mcp"), {
      requestInit: {
        headers: { Authorization: `Bearer ${process.env.NA_API_KEY}` },
      },
    })
    
    const client = new Client({ name: "my-app", version: "1.0.0" })
    await client.connect(transport)
    
    const result = await client.callTool({
      name: "na_search",
      arguments: { query: "cost center allocation", specialist: "auto", limit: 3 },
    })
  3. 3

    Python — official SDK

    Install with pip install mcp and use the Streamable HTTP client:

    Python
    import os
    from mcp import ClientSession
    from mcp.client.streamable_http import streamablehttp_client
    
    headers = {"Authorization": f"Bearer {os.environ['NA_API_KEY']}"}
    
    async with streamablehttp_client("https://totvs.mcp.newalgorithm.io/mcp", headers=headers) as (read, write, _):
        async with ClientSession(read, write) as session:
            await session.initialize()
            result = await session.call_tool(
                "na_search",
                {"query": "cost center allocation", "specialist": "auto", "limit": 3},
            )
  4. 4

    Plain HTTP — to check the credential

    Useful for testing the key before writing any code. The Accept header with both types is required by the Streamable HTTP transport:

    curl -X POST https://totvs.mcp.newalgorithm.io/mcp \
      -H "Authorization: Bearer na_live_xxxxxxxxxxxxxxxxx" \
      -H "Content-Type: application/json" \
      -H "Accept: application/json, text/event-stream" \
      -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

    Expected: na_prepare, na_search, na_route, na_specialists, na_version

  5. 5

    The tool parameters

    This is the complete contract — no other tool is exposed.

    Signatures
    na_search(query: str, specialist: str = "auto", limit: int = 3)
    na_route(query: str)
    na_specialists()
    na_version()

One key per application, not one key for all of them: that way you can revoke one integration without taking down the others. Every call goes out from your server — a key on the client is a leaked key.

Authentication and tool details in the Docs.