Skip to content

Commit 099a3fc

Browse files
authored
remove qualifiedNames from the pub dev api search (#146)
Closes #145 I did some testing myself and we easily get >10k tokens added to the context for a single query which is definitely too much for the value provided here.
1 parent e04e501 commit 099a3fc

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

pkgs/dart_mcp_server/lib/src/mixins/pub_dev_search.dart

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@ import '../utils/json.dart';
1414
/// Limit the number of concurrent requests.
1515
final _pool = Pool(10);
1616

17-
/// The number of reults to return for a query.
17+
/// The number of results to return for a query.
1818
// If this should be set higher than 10 we need to implement paging of the
1919
// http://pub.dev/api/search endpoint.
2020
final _resultsLimit = 10;
2121

22-
/// The number of identifiers we list per packages.
23-
final _maxIdentifiersListed = 200;
24-
2522
/// Mix this in to any MCPServer to add support for doing searches on pub.dev.
2623
base mixin PubDevSupport on ToolsSupport {
2724
final _client = Client();
@@ -56,7 +53,7 @@ base mixin PubDevSupport on ToolsSupport {
5653
return CallToolResult(
5754
content: [
5855
TextContent(
59-
text: 'No packages mached the query, consider simplifying it.',
56+
text: 'No packages matched the query, consider simplifying it.',
6057
),
6158
],
6259
isError: true,
@@ -80,9 +77,6 @@ base mixin PubDevSupport on ToolsSupport {
8077
(packageName) => (
8178
versionListing: retrieve('api/packages/$packageName'),
8279
score: retrieve('api/packages/$packageName/score'),
83-
docIndex: retrieve(
84-
'documentation/$packageName/latest/index.json',
85-
),
8680
),
8781
)
8882
.toList();
@@ -94,18 +88,6 @@ base mixin PubDevSupport on ToolsSupport {
9488
final packageName = packageNames[i];
9589
final versionListing = await subQueryFutures[i].versionListing;
9690
final scoreResult = await subQueryFutures[i].score;
97-
final docIndex = await subQueryFutures[i].docIndex;
98-
99-
Map<String, Object?> identifiers(Object index) {
100-
final items = dig<List>(index, []);
101-
return {
102-
'qualifiedNames': [
103-
for (final item in items.take(_maxIdentifiersListed))
104-
dig<String>(item, ['qualifiedName']),
105-
],
106-
};
107-
}
108-
10991
results.add(
11092
TextContent(
11193
text: jsonEncode({
@@ -144,7 +126,6 @@ base mixin PubDevSupport on ToolsSupport {
144126
.where((t) => (t as String).startsWith('publisher:'))
145127
.firstOrNull,
146128
},
147-
if (docIndex != null) ...{'api': identifiers(docIndex)},
148129
}),
149130
),
150131
);
@@ -164,8 +145,7 @@ base mixin PubDevSupport on ToolsSupport {
164145
description:
165146
'Searches pub.dev for packages relevant to a given search query. '
166147
'The response will describe each result with its download count, '
167-
'package description, topics, license, publisher, and a list of '
168-
'identifiers in the public api.',
148+
'package description, topics, license, and publisher.',
169149
annotations: ToolAnnotations(title: 'pub.dev search', readOnlyHint: true),
170150
inputSchema: Schema.object(
171151
properties: {

pkgs/dart_mcp_server/test/tools/pub_dev_search_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ void main() {
8282
'license:osi-approved',
8383
],
8484
'publisher': 'publisher:google.dev',
85-
'api': {
86-
'qualifiedNames': containsAll(['retry', 'retry.RetryOptions']),
87-
},
8885
});
8986
});
9087
}, _GoldenResponseClient.new);
@@ -161,7 +158,7 @@ void main() {
161158
expect(result.isError, isTrue);
162159
expect(
163160
(result.content[0] as TextContent).text,
164-
contains('No packages mached the query, consider simplifying it'),
161+
contains('No packages matched the query, consider simplifying it'),
165162
);
166163
});
167164
},

0 commit comments

Comments
 (0)