AL MCP: al_symbolrelations always fails, SymbolRelationsService is not registered in the standalone server
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
The failure is a missing DI registration: the stack trace points to McpServerFactory.RegisterSharedServices (McpServerFactory.cs line 317), which resolves SymbolRelationsService with GetRequiredService but never registers it. Start by checking that registration list against the other tools' services, then confirm the al_symbolrelations call succeeds with no project loaded. Done when the tool returns relations or the no-projects message instead of the generic error.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
1. Describe the bug
al_symbolrelations is advertised by the standalone AL MCP server (altool launchmcpserver) in tools/list, but every call to it fails. The client only receives the generic An error occurred invoking 'al_symbolrelations'.
The server's stderr shows the cause: the service behind the tool is not registered with the dependency injection container.
fail: ModelContextProtocol.Server.McpServer[1433779783]
"al_symbolrelations" threw an unhandled exception.
System.InvalidOperationException: No service for type 'Microsoft.Dynamics.Nav.CodeAnalysis.Workspaces.LanguageModelTools.SymbolRelations.SymbolRelationsService' has been registered.
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.Dynamics.BusinessCentral.ALMcp.McpServerFactory.<>c.<RegisterSharedServices>b__6_4(IServiceProvider sp) in X:\source\Prod\almcp\Services\McpServerFactory.cs:line 317
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite callSite, RuntimeResolverContext context)
...
at Microsoft.Extensions.DependencyInjection.McpServerBuilderExtensions.CreateTarget(IServiceProvider services, Type type)
at ModelContextProtocol.Server.AIFunctionMcpServerTool.InvokeAsync(RequestContext`1 request, CancellationToken cancellationToken)
The failure does not depend on the project or the arguments. I get the same exception:
- with no project loaded, and with projects loaded and their symbols already indexed
- with
symbolName+symbolKind(the example in the tool's own description), withsymbolIdfrom anal_symbolsearchresult, and with empty arguments - from an MCP client, and from raw JSON-RPC over stdio with no client involved
Other tools on the same server instance answer normally (al_symbolsearch, al_compile, al_inspectpage, al_getnextobjectid), so this looks specific to this tool's registration.
2. To Reproduce
No AL code is needed.
- Start the server with no project:
altool launchmcpserver --transport stdio - Send these lines on stdin:
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"repro","version":"1"}}}
{"jsonrpc":"2.0","method":"notifications/initialized"}
{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"al_symbolrelations","arguments":{"parameters":{"symbolName":"Customer","symbolKind":"Table"}}}}
- Read the response to
id2 on stdout and the exception on stderr.
3. Expected behavior
The tool returns the relations of the symbol. With no project loaded, it returns an actionable message, as al_symbolsearch does: No projects are loaded in the workspace. Use the al_addproject tool to add a project, then retry.
4. Actual behavior
{"result":{"content":[{"type":"text","text":"An error occurred invoking 'al_symbolrelations'."}],"isError":true},"id":2,"jsonrpc":"2.0"}
The exception above is written to stderr only. Nothing about it reaches the file set with --logfile, even at --loglevel Debug.
5. Versions:
- AL Language: 30.0.2863738, the latest pre-release on the Marketplace (
altool --version: 30.0.43.45776+9c432ef3dff6a3c4df683465da5f5c539f6a8bf1). Not tested on the release channel (18.1.2842859). - Visual Studio Code: not involved (standalone
altool); 1.144.0 installed - Business Central: not involved (the call fails before any server connection)
- List of Visual Studio Code extensions that you have installed: not applicable, reproduced outside Visual Studio Code
- Operating System:
- Windows
- Linux
- MacOS
Final Checklist
-
Search the issue repository to ensure you are reporting a new issue
-
Reproduce the issue after disabling all extensions except the AL Language extension (reproduced outside Visual Studio Code)
-
Simplify your code around the issue to better isolate the problem (no code needed)
- Ngôn ngữ chính
- PowerShell
- Star
- 891
- Fork
- 287
- Merge trung bình
- 4 giờ 7 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/AL
-
accepted al-tools bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
-
Fail to Run extensioĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
[Extensibility Request] Allow extending available font sizes in RichContent editor (sizes 5-7)Đang mởsuggestion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
igormcsouza/tether#278 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
microsoft/monaco-editor#5577 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/vscode-containers#655 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
pylint-dev/pylint#11791 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Document and enforce pull request review guidelinesCó thể đã có người làm @dashorst đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày