Skip to content

Commit 30a3ba0

Browse files
Revert text description enhancements - keep URLs simple
The enhanced text descriptions were not appropriate for these tools. Unlike static_map_image_tool (PR #104) which returns an IMAGE, these tools return URLs that should be opened by the user. The URL itself is the primary actionable content, and adding metadata made it less clear. LLMs can understand and use URLs directly. Keeping text content simple: - preview_style_tool: Returns URL only - style_comparison_tool: Returns URL only - geojson_preview_tool: Returns URL only All tests passing (520 tests).
1 parent 634eff2 commit 30a3ba0

4 files changed

Lines changed: 14 additions & 98 deletions

File tree

src/tools/geojson-preview-tool/GeojsonPreviewTool.ts

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,11 @@ export class GeojsonPreviewTool extends BaseTool<typeof GeojsonPreviewSchema> {
105105
const encodedGeoJSON = encodeURIComponent(geojsonString);
106106
const geojsonIOUrl = `https://geojson.io/#data=data:application/json,${encodedGeoJSON}`;
107107

108-
// Extract GeoJSON metadata for descriptive text
109-
const geojsonType = (geojsonData as { type: string }).type;
110-
let featureInfo = '';
111-
if (geojsonType === 'FeatureCollection') {
112-
const fc = geojsonData as {
113-
features: Array<{ geometry: { type: string } }>;
114-
};
115-
const featureCount = fc.features.length;
116-
const geometryTypes = [
117-
...new Set(fc.features.map((f) => f.geometry.type))
118-
];
119-
featureInfo = `Features: ${featureCount} (${geometryTypes.join(', ')})`;
120-
} else if (geojsonType === 'Feature') {
121-
const feature = geojsonData as { geometry: { type: string } };
122-
featureInfo = `Geometry: ${feature.geometry.type}`;
123-
} else {
124-
featureInfo = `Geometry: ${geojsonType}`;
125-
}
126-
127-
// Build descriptive text with GeoJSON metadata for better client compatibility
128-
// This ensures all MCP clients can display meaningful information
129-
const textDescription = [
130-
'GeoJSON preview generated successfully.',
131-
`Type: ${geojsonType}`,
132-
featureInfo,
133-
`Preview URL: ${geojsonIOUrl}`
134-
].join('\n');
135-
136-
// Build content array with text first (for compatibility)
108+
// Build content array with URL
137109
const content: CallToolResult['content'] = [
138110
{
139111
type: 'text',
140-
text: textDescription
112+
text: geojsonIOUrl
141113
}
142114
];
143115

src/tools/preview-style-tool/PreviewStyleTool.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,11 @@ export class PreviewStyleTool extends BaseTool<typeof PreviewStyleSchema> {
6565

6666
const url = `${MapboxApiBasedTool.mapboxApiEndpoint}styles/v1/${userName}/${input.styleId}.html?${params.toString()}${hashFragment}`;
6767

68-
// Build descriptive text with map metadata for better client compatibility
69-
// This ensures all MCP clients can display meaningful information
70-
const textDescription = [
71-
'Mapbox style preview generated successfully.',
72-
`Style: ${userName}/${input.styleId}`,
73-
`Preview URL: ${url}`,
74-
input.title !== undefined ? `Title display: ${input.title}` : null,
75-
input.zoomwheel !== undefined
76-
? `Zoom control: ${input.zoomwheel ? 'enabled' : 'disabled'}`
77-
: null
78-
]
79-
.filter(Boolean)
80-
.join('\n');
81-
82-
// Build content array with text first (for compatibility)
68+
// Build content array with URL
8369
const content: CallToolResult['content'] = [
8470
{
8571
type: 'text',
86-
text: textDescription
72+
text: url
8773
}
8874
];
8975

src/tools/style-comparison-tool/StyleComparisonTool.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,11 @@ export class StyleComparisonTool extends BaseTool<
101101
url += `#${input.zoom}/${input.latitude}/${input.longitude}`;
102102
}
103103

104-
// Build descriptive text with comparison metadata for better client compatibility
105-
// This ensures all MCP clients can display meaningful information
106-
const textDescription = [
107-
'Mapbox style comparison generated successfully.',
108-
`Before: ${beforeStyleId}`,
109-
`After: ${afterStyleId}`,
110-
input.zoom !== undefined &&
111-
input.latitude !== undefined &&
112-
input.longitude !== undefined
113-
? `View: ${input.latitude}, ${input.longitude} @ zoom ${input.zoom}`
114-
: null,
115-
`Comparison URL: ${url}`
116-
]
117-
.filter(Boolean)
118-
.join('\n');
119-
120-
// Build content array with text first (for compatibility)
104+
// Build content array with URL
121105
const content: CallToolResult['content'] = [
122106
{
123107
type: 'text',
124-
text: textDescription
108+
text: url
125109
}
126110
];
127111

test/tools/geojson-preview-tool/GeojsonPreviewTool.test.ts

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,8 @@ describe('GeojsonPreviewTool', () => {
4040
expect(result.content[0].type).toBe('text');
4141
const content = result.content[0];
4242
if (content.type === 'text') {
43-
// Verify descriptive text includes metadata
44-
expect(content.text).toContain('GeoJSON preview generated successfully');
45-
expect(content.text).toContain('Type: Point');
46-
expect(content.text).toContain('Geometry: Point');
47-
expect(content.text).toContain('Preview URL:');
48-
// Verify URL is present in the text
49-
expect(content.text).toContain(
50-
'https://geojson.io/#data=data:application/json,'
43+
expect(content.text).toMatch(
44+
/^https:\/\/geojson\.io\/#data=data:application\/json,/
5145
);
5246
expect(content.text).toContain(
5347
encodeURIComponent(JSON.stringify(pointGeoJSON))
@@ -110,14 +104,8 @@ describe('GeojsonPreviewTool', () => {
110104
expect(result.isError).toBe(false);
111105
const content = result.content[0];
112106
if (content.type === 'text') {
113-
// Verify descriptive text includes metadata
114-
expect(content.text).toContain('GeoJSON preview generated successfully');
115-
expect(content.text).toContain('Type: Feature');
116-
expect(content.text).toContain('Geometry: Point');
117-
expect(content.text).toContain('Preview URL:');
118-
// Verify URL is present in the text
119-
expect(content.text).toContain(
120-
'https://geojson.io/#data=data:application/json,'
107+
expect(content.text).toMatch(
108+
/^https:\/\/geojson\.io\/#data=data:application\/json,/
121109
);
122110
expect(content.text).toContain(encodeURIComponent(geoJSONString));
123111
}
@@ -154,16 +142,8 @@ describe('GeojsonPreviewTool', () => {
154142
expect(result.isError).toBe(false);
155143
const content = result.content[0];
156144
if (content.type === 'text') {
157-
// Verify descriptive text includes metadata
158-
expect(content.text).toContain('GeoJSON preview generated successfully');
159-
expect(content.text).toContain('Type: FeatureCollection');
160-
expect(content.text).toContain('Features: 2');
161-
expect(content.text).toContain('Point');
162-
expect(content.text).toContain('LineString');
163-
expect(content.text).toContain('Preview URL:');
164-
// Verify URL is present in the text
165-
expect(content.text).toContain(
166-
'https://geojson.io/#data=data:application/json,'
145+
expect(content.text).toMatch(
146+
/^https:\/\/geojson\.io\/#data=data:application\/json,/
167147
);
168148
expect(content.text).toContain(
169149
encodeURIComponent(JSON.stringify(featureCollection))
@@ -217,14 +197,8 @@ describe('GeojsonPreviewTool', () => {
217197
expect(result.isError).toBe(false);
218198
const content = result.content[0];
219199
if (content.type === 'text') {
220-
// Verify descriptive text includes metadata
221-
expect(content.text).toContain('GeoJSON preview generated successfully');
222-
expect(content.text).toContain('Type: Feature');
223-
expect(content.text).toContain('Geometry: Point');
224-
expect(content.text).toContain('Preview URL:');
225-
// Verify URL is present in the text
226-
expect(content.text).toContain(
227-
'https://geojson.io/#data=data:application/json,'
200+
expect(content.text).toMatch(
201+
/^https:\/\/geojson\.io\/#data=data:application\/json,/
228202
);
229203
// Verify URL contains properly encoded content
230204
expect(content.text).toContain('%22'); // Encoded quotes

0 commit comments

Comments
 (0)