Hey fellow reader!
I hope am not too late for the MCP party, and I hope with this short post to add meaningful contribution to the already awesome resources out there.
In short:
I have decided to try out building custom MCP server which exposes as a resource specific documentation and connect it Amazon Q.
I have used typescript sdk Link here.
Lets get started then!
- create a directory
mkdir mcp-server
(side note: I am using pnpm
, as package manager)
- inside the newly created directory run
pnpm init
to generate package.json file. Once it is generated, navigate to it and replace script section with :
script: {
"build": "tsc && chmod 755 build/index.js"
}
you are pointing typescript where to store your public endpoint , giving the necessary permission too. After that you would need to create your tsconfig.json.
tsc init
make the needed changes:
outDir: './build'
target: 'es2022'
module: 'NodeNext'
last two would allow top level await
to be used.
Install @modelcontextprotocol/sdk
.
We will be using low-level server. Examples from the mcp repository : Low-level mcp-server.
We can start.
Create a src
directory and inside it create a file called index.ts
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import * as fs from 'node:fs/promises';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const server = new Server({
name: 'docs-demo',
version: '1.0.0'
}, {
capabilities: {
resources: {},
tools: {}
}
}
);
const docFiles = await fs.readFile('./src/docs/integration.md');
server.setRequestHandler(ListResourcesRequestSchema, async () => {
return {
resources:[
{
uri: 'file://' + __dirname + '/docs/integration.md',
name: 'Integration docs',
mimeType: 'text/plain'
}
]
}
});
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
const uri = request.params.uri;
if (uri === 'file://' + __dirname + '/docs/integration.md') {
return {
contents: [
{
uri,
mimeType: 'text/plain',
text: docFiles.toString('utf-8')
}
]
}
}
throw new Error('Resource not found');
});
const transposrt = new StdioServerTransport();
console.log('Starting server...');
await server.connect(transposrt)
Create a docs
folder in you src
folder. There we will add our integration.md file. You would need an assets
folder with our diagram. You can download this one!
content of integratiion.md file
# Integration awesome105
### Build a simple flow with AWS SQS , AWS SNS and AWS Lambda

Now we need to install Amazon-q CLI. Here is an excellent tutorial how to install amazon-q on a different os systems.
Link to the tutorial
I have used:
brew install amazon-q
After installation check if it is installed:
q version
Now comes the most important part. To let know amazon-q that there is a mcp-server. Amazon-q will be installed in a directory ~/.aws/amazonq
. Get into this directory like this:
cd ~/.aws/amazonq
Now type ls
to list everything in this directory - should not have mcp.json
. Type in the terminal:
touch mcp.json
copy and paste this and save:
{
"mcpServers": {
"docs-demo": {
"command": "node", // command that will run your index.js
"args": [
"/absolute_path/build/index.js"] //absolute path to your index.js
}
}
}
Now time to test!
Go back to your terminal and type q chat
. You should be able to see this ....
Now lets ask amazon-q to find documentation for our awesome105
integration and explain the diagram associated with it.
And voila...
This is truly amazing! Could you imagine what horizons this feature opens? For me beyond my dreams! Thank you Amazon-q!
Thank you for reading! Please leave a comment and let me know what cool projects you came up with using mcp-server and amazon-q!
Top comments (1)
Great article- thank you for sharing, Denise!