Find Calls to External APIs
calls_externalFinds code that calls external APIs by pattern to assess AOT/trimming readiness, security surface, or dependency footprint.
Instructions
Find the code that calls an EXTERNAL member - BCL or package - whose key contains 'pattern'. find_usages answers for solution symbols only; find_by_side_effects classifies the same calls into effect tokens.
Use it for AOT/trimming readiness, security surface or dependency footprint: pass the risky or external API as 'pattern', e.g. 'Process.Start' or 'DateTime.UtcNow'. It is the only search argument; there is no 'symbol'.
Returns scope, pattern, methodsScanned, matches - a capped envelope of at most 200 hits, sorted by type and name, not ranked - and testMatchesFiltered (units the test filter removed, outside methodsScanned; omitted at 0). A hit carries name, declaringType, namespace, matchedCalls (invoked methods and method groups, keys like 'System.IO.File.ReadAllText(string)') and matchedReads (external properties read or written, like 'System.DateTime.UtcNow'). The units scanned are methods plus every accessor and constructor with a body, under their metadata names (get_X, set_X, .ctor), and, unscoped, each top-level-statement file ('Program.cs (top-level)'); an initializer counts toward the constructor that runs it.
The pattern is a case-insensitive substring of the whole key, parameter list included, so a type name also hits the units that only pass that type to another API. It is an open vocabulary (no did-you-mean); empty is strong, not absolute. Not recorded: an external field read ('string.Empty'), a bare 'new X()', operators and conversions, indexers, event subscriptions and compiler-lowered calls (using, foreach, await). Cross-check a surprising empty against the declaring type ('DateTime', not 'DateTime.UtcNow'). A 'note' leads the answer when it is empty - it says when only the test filter emptied it - and when a project's core references did not resolve: an unresolved call records no key.
Read-only; works on a recalled session. Test-project code is excluded by default (includeTests=true includes it). scope is 'solution' or a namespace prefix, matched case-insensitively on segment boundaries.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>",
"pattern": "<pattern>"
},
"name": "calls_external"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| scope | No | 'solution' (default) or a namespace prefix (e.g. 'MyApp.Infrastructure') to narrow scope. | solution |
| pattern | Yes | A substring of the external (BCL/third-party) call key to match (case-insensitive), e.g. 'Process.Start', 'File.', 'Assembly.Load', 'System.Reflection', 'JsonSerializer'. Required - a very broad pattern (e.g. 'System') truncates at 200. | |
| sessionId | Yes | The session_id returned by analyze_solution. Also takes an absolute .sln/.slnx/.slnf path, analyzed on first use. | |
| includeTests | No | Include test-project methods (default false - production focus; test setup/assertions calling external APIs would otherwise drown the signal). |