Tencent/WeKnora · error
MCP service not found
Error message
MCP service not found
What it means
Returned by StartAuthorizationForService when GetByID succeeds but returns a nil service — the MCP service with that ID does not exist for the tenant (or was deleted). Distinct from a repository error: the lookup worked and definitively found nothing.
Source
Thrown at internal/mcp/oauth_manager.go:168
return authURL, state, nil
}
// StartAuthorizationForService loads the MCP service by ID and starts the
// authorization-code flow, returning the URL the user must open. It is a
// convenience for callers (e.g. IM channels) that only hold a service ID and
// cannot reach the MCP service lookup directly.
func (m *OAuthManager) StartAuthorizationForService(
ctx context.Context,
tenantID uint64,
principal types.Principal,
serviceID, redirectURI, frontendRedirect string,
) (string, error) {
service, err := m.serviceRepo.GetByID(ctx, tenantID, serviceID)
if err != nil {
return "", fmt.Errorf("failed to load MCP service: %w", err)
}
if service == nil {
return "", fmt.Errorf("MCP service not found")
}
authURL, _, err := m.StartAuthorization(ctx, service, tenantID, principal, redirectURI, frontendRedirect)
return authURL, err
}
// CompleteAuthorization handles the provider callback: it validates state,
// exchanges the code for tokens (PKCE), and persists the per-user token.
// Returns the frontend redirect URL and service ID recorded at
// StartAuthorization time so the caller can recycle any cached transport that
// still carries the previous OAuth client registration.
func (m *OAuthManager) CompleteAuthorization(
ctx context.Context, state, code string,
) (frontendRedirect, serviceID string, err error) {
ctx, cancel := context.WithTimeout(context.WithoutCancel(ctx), oauthCallbackTimeout)
defer cancel()
st, err := m.states.Take(ctx, state)
if err != nil {View on GitHub (pinned to 988cbb0330)
Solutions
- Verify the service ID with the tenant
- Re-create or re-register the MCP service before retrying authorization
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/mcp/oauth_manager.go:168 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/be537e30f582f166.
Report an issue: GitHub.