Saltar a contenido

Adding SAP Business One MCP Server to Goose

Vigencia por confirmar: guía del ejemplo de referencia de SAP, escrita para desarrollo local. En Compulandia el servidor corre en Cloud Run y los usuarios se conectan desde Claude (ver Runbook).

This guide provides step-by-step instructions for connecting the B1 MCP Server to Goose using OAuth 2.0 authentication and testing it with SAP Business One Service Layer.


What is Goose?

Goose is an extensible open-source AI agent that runs on your machine. Unlike IDE-embedded assistants, Goose works as a standalone agent — available as a desktop app, CLI, and API — and can handle code, research, writing, automation, data analysis, and more. It supports the Model Context Protocol (MCP), which means any MCP server can be added as an extension to expand what Goose can do.


Prerequisites

  • Goose >= 1.38.0 installed (desktop app). See https://goose-docs.ai/docs/getting-started/installation for installation instructions.
  • The B1 MCP server is running in AUTHENTICATION_MODE=oauth and reachable (e.g. https://localhost:3000/mcp).
  • SAP B1 Service Layer and SLD are configured and accessible.
  • Keycloak realm configured with the b1_mcp:access scope — see Keycloak setup. Step 4 (trusted hosts for Dynamic Client Registration) is required for Goose.

Keycloak Setup for Goose

Goose has a built-in OAuth 2.0 Authorization Code + PKCE flow. When it connects to an OAuth-protected MCP server, it automatically discovers the authorization endpoints from /.well-known/oauth-protected-resource and opens a browser window for login. Goose registers itself in Keycloak automatically at runtime using OAuth 2.0 Dynamic Client Registration (RFC 7591) — no manual client registration is required.

For the complete four-step Keycloak configuration (client scope, audience mapper, trusted hosts), see Keycloak setup.


Add the MCP Server to Goose

  1. Open the Goose desktop app.
  2. Click Extensions in the sidebar.
  3. Click Add custom extension.
  4. Fill in the extension details:
Field Value
Name b1-mcp-server
Type Streamable HTTP
Description SAP Business One MCP Server
Endpoint https://localhost:3000/mcp
Timeout 10000
  1. Click Add Extension and confirm the extension is enabled.

Authenticate

When Goose first calls the MCP server, it detects the OAuth metadata and initiates the PKCE flow automatically:

  1. Goose opens your browser to the Keycloak login page.

goose-Keycloak-login

  1. Log in with your SAP B1 credentials and grant access to Goose

goose-Keycloak-grant

  1. Keycloak redirects back to Goose with an authorization code, which Goose exchanges for an access token automatically.

goose-Keycloak-auth

Select a Company

Once authenticated, select a company before calling any entity tools:

  1. Ask Goose: List available SAP Business One companies
  2. Goose calls b1_list_companies and returns the companies your user is entitled to access.

goose-list-company

  1. Ask Goose: Select company SBODEMOUS (use the CompanySchemaName from the previous step)
  2. Goose calls b1_select_company to bind the session to that company.

goose-select-company

All subsequent entity tool calls will use the selected company context.


Examples

Once connected and a company is selected, you can interact with SAP Business One data using natural language. Goose follows the 3-step discovery pattern automatically.

Read Sensitive Data

  1. Ask Goose: Get the card code, card name, address, zip code, credit limit of the business partner with card code = 'BA01'
  2. Goose calls b1_find_entities to locate the BusinessPartners entity.
  3. Goose calls b1_get_entity_schema to retrieve the schema and available properties for the BusinessPartners entity.
  4. Goose calls b1_read to retrieve the requested properties for the specified business partner. goose-read-bp.png goose-bp

Troubleshooting

Authentication failures

  • Confirm the server is running: curl http://localhost:3000/health
  • Verify the endpoint URL in the extension config matches the running server address.
  • Restart Goose after making configuration changes.
  • Check Keycloak trusted hosts configuration if authentication fails with a host verification error — see Keycloak setup.
  • If the OAuth flow still fails or token expires, try the following recovery steps in order:
  • Clear your browser cache and cookies.
  • Restart the MCP server.
  • Remove and re-add the extension in Goose.
  • Restart Goose.

Write operations blocked

  • If MCP_HUMAN_CONFIRMATION_ENABLED=true, Goose will display an elicitation confirmation prompt before write operations. Approve the prompt to proceed, or set MCP_HUMAN_CONFIRMATION_ENABLED=false in .env for automated pipelines.